9
11

ROS2コマンド一覧

Last updated at Posted at 2020-06-16

ROS2関係トップページへ

概要

ROS2のコマンド一覧.
基本的にubuntuコマンド.

colcon

colconの説明は,colcon -hで見ることができる.またcolcon build -hも有用である.

colcon build

colconビルドで便利なオプションのページがオプションが表になっていて見やすく素敵.

通常ビルド

$ colcon build --symlink-install

いくつかのパッケージのみビルドしたい場合

$ colcon build --symlink-install --packages-up-to [package1 package2 ...]

colcon test

パッケージのテスト

キャッシュをクリア

一旦ビルドに失敗したら,失敗した情報がそのまま残ってしまい直してもビルドに失敗することがある.キャッシュをクリアしてやり直す.

$ colcon build --cmake-clean-cache

それでもだめなら,プロジェクトの以下のディレクトリを削除するとよい.

  • build/
  • install/
  • log/

ros2

ros2 -hで色々ヘルプを見ることができる.サブコマンドも-hで細かくヘルプを見ることができる.

ros2 pkg create

自動作成される設定ファイルなどについての詳細情報はROS2コマンド一覧:ros2 pkg createを参照のこと.

  • ros2 pkg create [options] [package_name]
    • options
      • --build-type [type]
        • type
          • ament_cmake
            • デフォルト
          • ament_python
      • --node-name [node_name]
        • node_name
          • 指定するとhello world的なひな形のnode実行ファイルを作ってくれる
      • --dependencies [depend1 depend2 ...]
        • depend1...
          • 指定すると自動的に依存関係の必要なところをpackage.xmlとCMakeList.txtに書いてくれる.

おすすめコマンド

パッケージ名の例:my_package
必要な依存関係の例:rclcpp

CMakeの場合

$ ros2 pkg create --build-type ament_cmake my_package --dependencies rclcpp

ros2 run

  • ros2 run [パッケージ名] [ターゲット名] [options]
    • options
      • --ros-args --params-file [file名]
        • YAMLファイルをパラメータとして読み込む
        • ros2 runを行ったディレクトリからの相対パスで指定する.
      • -r
        • 名前を変えるオプション
        • -r __ns:=<new node namespace>
          • 名前空間を右項で設定
        • -r __node:=<new node name>
          • ノード名を右項で設定
        • -r <old name>:=<new name>
          • topic/serviceの名前をリマッピング
        • 参考

ros2状態確認

詳しくはIntrospection with command line toolsを参照.

よく使うもの

  • ros2 node list
    • ノード一覧の表示
  • ros2 topic list
    • トピック一覧の表示
  • ros2 topic pub /topic_test example/msg/String '{data: hello}'
    • example/msg/Stringにデータをpublish
  • ros2 service list
  • ros2 action list
  • ros2 interface list
    • メッセージ一覧の表示
  • ros2 interface show example_interfaces/msg/String
    • example_interfaces/msg/Stringの構造を表示

###その他
Dashingまではros2 msg, ros2 srvコマンドであったが,Eloquentからros2 interfaceに統合された模様(Tutorial Creating custom ROS2 msg and srv).topicは要調査.

Dashingの場合

  • ros2 msg list
    • メッセージ一覧の表示
  • ros2 msg show std_msgs/String
    • メッセージであるstd_msgsのStringの構造を表示
9
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
11