Ask Your Question
1

roslaunch - params for included launch files

asked 2019-08-08 16:18:06 -0500

pring gravatar image

updated 2019-08-08 16:19:30 -0500

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>
edit retag flag offensive close merge delete

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,

<arg name="rgb_topic" value="/camera/color/image_raw"/>

rmv24 gravatar imagermv24 ( 2019-08-08 17:59:19 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-08-08 20:15:55 -0500

updated 2019-08-08 20:17:05 -0500

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.

edit flag offensive delete link more

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"/>
pring gravatar imagepring ( 2019-08-09 08:47:33 -0500 )edit

mention the node you're trying to run, and under that block use the command to set your parameters.

rmv24 gravatar imagermv24 ( 2019-08-09 13:53:18 -0500 )edit

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.

adamconkey gravatar imageadamconkey ( 2019-08-09 17:46:16 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-08-08 16:18:06 -0500

Seen: 37 times

Last updated: Aug 08