roslaunch - params for included launch files
Hello, I would like to roslaunch other apps within my project's roslaunch xml file. I would also like to attach params to start the app with.
The following is what I have at the moment, however it doesn't apply the params (it does launch the two nodes, however).
<launch>
<include file="$(find realsense2_camera)/launch/rs_camera.launch" >
<param name="/camera/realsense2_camera/align_depth" type="bool" value="true" />
<param name="/camera/realsense2_camera/filters" type="string" value="pointcloud" />
</include>
<include file="$(find rtabmap_ros)/launch/rtabmap.launch" >
<param name="rtabmap_args" type="string" value="--delete_db_on_start" />
<param name="depth_topic" type="string" value="/camera/aligned_depth_to_color/image_raw" />
<param name="rgb_topic" type="string" value="/camera/color/image_raw" />
<param name="camera_info_topic" type="string" value="/camera/color/camera_info" />
<param name="approx_sync" type="string" value="false" />
</include>
</launch>
Asked by pring on 2019-08-08 16:18:06 UTC
Answers
You should be using args instead of params. The param
tag sets values on the ROS parameter server, while the arg
allows you to set inputs from either the command line or another launch file. I like to create args in my own launch file and pass them to others. This way you can change the arg values for your own launch file from the command line and it's possible to include your launch file in another if needed. It's also easier to see what your options are for the launch file when they're all in one place at the top:
<launch>
<arg name="align_depth" default="true"/>
<arg name="filters" default="pointcloud"/>
<arg name="rtabmap_args" default="--delete_db_on_start"/>
<arg name="depth_topic" default="/camera/aligned_depth_to_color/image_raw"/>
<arg name="rgb_topic" default="/camera/color/image_raw"/>
<arg name="camera_info_topic" default="/camera/color/camera_info"/>
<arg name="approx_sync" default="false"/>
<!-- =============================================================================== -->
<include file="$(find realsense2_camera)/launch/rs_camera.launch" >
<arg name="align_depth" value="$(arg align_depth)"/>
<arg name="filters" value="$(arg filters)"/>
</include>
<include file="$(find rtabmap_ros)/launch/rtabmap.launch">
<arg name="rtabmap_args" value="$(arg rtabmap_args)"/>
<arg name="depth_topic" value="$(arg depth_topic)"/>
<arg name="rgb_topic" value="$(arg rgb_topic)"/>
<arg name="camera_info_topic" value="$(arg camera_info_topic)"/>
<arg name="approx_sync" value="$(arg approx_sync)"/>
</include>
</launch>
Note I changed the names of the args going to rs_camera.launch
as I assume you're using this file, which accepts the args align_depth
and filters
.
Asked by adamconkey on 2019-08-08 20:15:55 UTC
Comments
Thank you!
There is a param that I would like to set in rtabmap - /rtabmap/Odom/ResetCountdown .. how could I do this in the launch file?
From the rtabmap github, it is referenced as a param ...
<param name="Odom/ResetCountdown" type="string" value="1"/>
Asked by pring on 2019-08-09 08:47:33 UTC
mention the node you're trying to run, and under that block use the command to set your parameters.
Asked by rmv24 on 2019-08-09 13:53:18 UTC
You can set it from your launch file as something like
<group ns="rtabmap/Odom">
<param name="ResetCountdown" value="1"/>
</group>
But if the param is being set also in another file then it may get overset. If that's the case, you could change the param loading to load what is passed in from an arg, and then pass the arg from your launch file like above in my answer.
Asked by adamconkey on 2019-08-09 17:46:16 UTC
Comments
I think you ought to include arguments if you're calling a launch file. params can be set only when you run ros nodes. So you can set something like,
Asked by rmv24 on 2019-08-08 17:59:19 UTC