1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

roslaunchで引数からrvizを起動するかどうか切り替える

Last updated at Posted at 2021-10-14

launchファイルはそれ単体で使う場合にはrvizを起動して、他のlaunchから呼ばれて、そちらでrvizをするというようなことが多く引数からオンオフの切り替えができると便利です。

以下のように引数guiを定義して、ifで条件分岐によってrvizの起動するかしないかを決めます。

rviz.launch
<launch>

  <arg name="gui" default="false" />
  
  <group if="$(arg gui)">
    <node name="rviz"
          pkg="rviz" type="rviz"
          args="-d $(find aaaa)/rviz/bbbb.rviz"/>
  </group>

</launch>

実行は次のように行います。

  • from cmd line
# rvizを実行しない場合
roslaunch aaa_pkg rviz.launch 

# rvizを実行する場合
roslaunch aaa_pkg rviz.launch gui:=true
  • from launch file
from_launch.lauch
<launch>

<include file="$(find aaa)/launch/rviz.launch">
  <arg name="gui" value="true"/>
</include>

</launch>
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?