sphinxcontrib-ros紹介

第7回ROS勉強会@ドワンゴ

by otamachan

(http://otamachan.github.io/slide-sphinxcontrib-ros/)

1

自己紹介

2

ところで

3

私は好きではありません

ドキュメント書いていたはずなのに、気づいたら、

  • 音声認識で文書生成するプログラム書いてる
  • Texのマクロいじってる
  • Sphinxの拡張書いてる

ことが多々・・・

そんな私ですが、今日はROSのドキュメンテーションツールを紹介します。

4

目次

  1. Sphinxの紹介
  2. sphinxcontrib-rosの紹介
  3. まとめ
5

まずはSphinxの紹介

Sphinx とは
  • Pythonで書かれたドキュメンテーションツール
  • reStructuredText(マークアップ言語)でドキュメントを記述
  • HTML, PDF, ePub等出力フォーマットが豊富
  • HTMLのテーマも豊富
  • 多言語対応のドキュメントも書ける
  • Python のドキュメントに使用されている
  • ReadTheDoc といったホスティングサービスも
6

こんな感じで書くと

すごいドキュメント
------------------

始めに
======

すごいドキュメントに関して記述します。
`リンク <http://www.ros.org>`_ を参考にしてください。

* リスト1
* リスト2

コード
======

.. code-block:: c

   int main() {
       printf("Hello World!\n");
   }

参考文献
========

=========== ==================================
言語        本の名前
=========== ==================================
Ruby        dRubyによる分散・Webプログラミング
Python      集合知プログラミング
=========== ==================================
7

こんな風にかっこよく出力してくれる

8

良い点(個人的な感想)

9

使いづらい点(個人的な感想)

10

ロボット界でもちらほらSphinxが

11

NAOqi(Pepper)

12

fetch robotics

13

Choreonoid

14

ROSのドキュメントといえばROS wiki

15

Wiki拡張で書けて

16

パッケージやAPIを出力してくれる

17

かっこいい

18

SphinxでもROSのドキュメントかっこよく書きたい

19

sphinxcontrib-rosの紹介

sphinxcontrib-ros

SphinxでROSのドキュメンテーションをするための拡張

  1. シンタックスハイライト
  2. パッケージ概要
  3. メッセージ定義
  4. インタフェース

が書ける。

20

インストール

  1. パッケージインストール

    $ pip install sphinxcontrib-ros
    
  2. 設定ファイル(conf.py)に追加

    # 拡張の追加
    extenstions += ['sphinxcontrib.ros']
    # パッケージパスを指定
    ros_base_path = ['../src']
    
21

(1)シンタックスハイライト

シンタックスハイライト
======================

.. code-block:: rostype

   # The joint trajectory to follow
   trajectory_msgs/JointTrajectory trajectory

   # Tolerances for the trajectory.  If the measured joint values fall
   # outside the tolerances the trajectory goal is aborted.  Any
   # tolerances that are not specified (by being omitted or set to 0) are
   # set to the defaults for the action server (often taken from the
   # parameter server).

   # Tolerances applied to the joints as the trajectory is executed.  If
   # violated, the goal aborts with error_code set to
   # PATH_TOLERANCE_VIOLATED.
   JointTolerance[] path_tolerance

   # To report success, the joints must be within goal_tolerance of the
   # final trajectory value.  The goal must be achieved by time the
   # trajectory ends plus goal_time_tolerance.  (goal_time_tolerance
   # allows some leeway in time, so that the trajectory goal can still
   # succeed even if the joints reach the goal some time after the
   # precise end time of the trajectory).
   #
   # If the joints are not within goal_tolerance after "trajectory finish
   # time" + goal_time_tolerance, the goal aborts with error_code set to
   # GOAL_TOLERANCE_VIOLATED
   JointTolerance[] goal_tolerance
22

出力

23

(2)パッケージ概要

すごいパッケージ
================

パッケージ概要
--------------

.. ros:package:: my_great_package

   :version: 0.1.0
   :author: Great Person

   これはスゴイパッケージです。

   こんな実装になっています。

他のセクション
--------------

実装は、 :ros:pkg:`my_great_package` を参考にしています。
24

出力

25

めんどくさい

26

package.xml

<?xml version="1.0"?>
<package>
  <name>my_great_package_auto</name>
  <version>0.0.0</version>
  <description>The is a great package</description>
  <maintainer email="john@mail.com">John Smith</maintainer>
  <license>BSD</license>
  <url>http://google.com</url>
  <author email="jane.doe@example.com">Jane Doe</author>
  <build_depend>another_package</build_depend>
  <buildtool_depend>package_x</buildtool_depend>
  <run_depend>package_y</run_depend>
  <test_depend>package_z</test_depend>
  <export>
  </export>
</package>
27

autopackage

すごいパッケージ
================

パッケージ概要
--------------

.. ros:autopackage:: my_great_package_auto


他のセクション
--------------

実装は、 :ros:pkg:`my_great_package_auto` を参考にしています。
28

出力

29

(2)メッセージ定義

メッセージ一覧
==============

すごいメッセージ
----------------

.. ros:message:: my_great_package/GreatMessage

   :field Header header: ヘッダ
   :field float64 x: x座標

   すごいメッセージです。

すごいアクション
----------------

.. ros:action:: my_great_package/GreatAction
30

出力

31

めんどくさい

32

GreatAutoMessage.msg

# Message Description

Header header # header

float32 x # x position
float32 y # y position

my_great_package/GreatMessage field # great field
33

automessage

メッセージ一覧
==============

すごいメッセージ
----------------

.. ros:automessage:: my_great_package_auto/GreatAutoMessage
   :field-comment: right1

すごいアクション
----------------

.. ros:action:: my_great_package/GreatAction
34

出力

35

オプションとか

36

(3)インターフェース定義

すごいノード
============

ノードAPI
---------

.. ros:node:: my_great_package/GreateNode

   :pub geometry_msgs/Vector3 ~pos: position of the robot

   :sub geometry_msgs/Twist ~vel: reference velocity

   :srv  std_srvs/Trigger ~trigger: trigger for start

   :srv_called std_srvs/Empty ~beep: beep service

   :action control_msgs/GripperCommand ~gripper: gripper action of the robot

   :action_called moveit_msgs/Pickup ~pickup: pickup action

   :param int32 clients: number of clients
   :param-default clients: 10

   :param_set int32 motors: number of motors

   これはすごいノードです。
37

出力例

38

サンプル

Indigo/Jadeの

を出力してみました。(TravisCI/Ubuntu14.04)

39

出力

40

自プロジェクトで使う時

41

大丈夫

42

適当に参照しても

sphinx.ext.intersphinx
=======================

参照
----

このパッケージは :ros:pkg:`actionlib` を参考にしています。

:ros:msg:`control_msgs/JointControllerState```i_clamp`` には対応していません。

型定義
------

.. ros:message:: my_package/MyNewMessage

   :field Header header: Header
   :field geometry_msgs/Vector3 acc: Acceleration of the robot
43

出力

44

まとめ

45

今後のTODO

46

ありがとうございました

47