LoginSignup
5
4

More than 5 years have passed since last update.

launchの起動を遅延させる"timed_roslaunch"が使いやすくなりました

Last updated at Posted at 2016-12-13

はじめに

以前投稿したlaunchファイルを指定時間sleep後に起動する "timed_roslaunch" が,fornoさんのPull-Requestによって改良されたので,ご報告します.

改めて,fornoさんに感謝申し上げます.

(また,これを書いている日よりも前の日程でAdventCalenderに空きがあったので,埋めさせて頂きました.)

そもそも timed_roslaunch とは?

任意のlaunchファイルの起動時間を,指定秒だけ遅らせる機能を持つノードです.雛形はROS Answers - Can I run a bash script using roslaunch?です.

例えば,下記のような用途に利用可能です.

  • 実機で,特定のノードだけはドライバの初期化完了後に実行したい
  • GAZEBOで,特定のノードは仮想空間構築およびプラグイン読み込みの完了後に実行したい

このように実行しないとエラーを吐いてしまうノードに遭遇することが稀にありますので,その対策に使えるという位置づけです.

地味ですが,意外と需要はあるかも(?)しれません.

どう使うの?

リポジトリ

下記リポジトリをクローンし,catkin_makeします.

コマンドからの利用

従来仕様

rosrun timed_roslaunch timed_roslaunch.sh [number of seconds to delay] [rospkg] [roslaunch file] [arguments (optional)]
  • ノードを直接実行する.
  • timed_roslaunch.shの引数は1つ.
  • 必要なパラメータをまとめてこの1つの引数の中に記述している.

追加仕様

roslaunch timed_roslaunch timed_roslaunch.launch time:=[number of second to delay] pkg:=[rospkg] file:=[roslaunch file] value:=[arguments (optional)]
  • 起動用のlaunchファイルから実行する.
  • 遅延時間,pkg名,ファイル名,遅延対象launchファイル用の引数,ノード名,をそれぞれ個別の引数として渡す.

launchファイルからの呼び出し

従来仕様

<launch>
  <node pkg="timed_roslaunch" type="timed_roslaunch.sh"
    args="2 turtlebot_navigation amcl_demo.launch initial_pose_x:=17.0 initial_pose_y:=17.0"
    name="timed_roslaunch" output="screen" />
</launch>
  • 引数が少ないので行数は短くて済むが,引数の解釈がしにくい.

追加仕様

<launch>
  <include file="$(find timed_roslaunch)/launch/timed_roslaunch.launch">
    <arg name="time" value="2" />
    <arg name="pkg" value="turtlebot_navigation" />
    <arg name="file" value="amcl_demo.launch" />
    <arg name="value" value="initial_pose_x:=17.0 initial_pose_y:=17.0" />
    <arg name="node_name" value="timed_roslaunch" /> <!-- This is optional argment -->
  </include>
</launch>
  • 視認性が高く,引数の管理がし易い.

おわりに

任意のlaunchファイルの起動を遅らせる方法について述べました.ただし,1つ忘れてはならないことがあります.

本質的な問題を解決するには「起動を遅らせなければエラーを吐いてしまうノード側を修正する必要がある」という点です.

言っている私本人が使い込んでしまっているのですが,一応頭の隅には入れておくべきと思います ^^;

5
4
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
5
4