Rosanswers logo

To re-use other packages in the ROS2 ecosystem, it's often advantageous to directly re-use the launch files provided with a package by using IncludeLaunchDescription. Often the launch files from other included packages provide launch arguments to overwrite parameters, node names, namespaces, and sometimes topics. What if they don't? Is there another programmatic way to overwrite these values without the use of launch args?

In particular I'm curious about topics. I want to use IncludeLaunchDescription to reuse a launch file from another package but I also would like to remap some topics to match my topic scheme (already defined by use of many bags, other node's expectations, etc.). It seems the only option now is to copy the provided launch into my package and rework it to support my topic, param, node, and namespace names. Is there another way that promotes reuse in a more flexible way?

Originally posted by jeremya on ROS Answers with karma: 275 on 2022-01-25

Post score: 0


1 Answer 1


Rosanswers logo

I haven't tried it out myself, but it sounds to me like a GroupAction and a SetRemap action might be what you're looking for

GroupAction lets you scope the context of different nodes / launch configurations.

SetRemap then lets you define remapping rules within that context

Originally posted by shonigmann with karma: 1567 on 2022-01-25

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by tnajjar on 2022-01-25:
Yes that should be the way. I implemented it myself not so long ago so if you have troubles let us know.

Comment by jorgemia on 2022-07-18:
Is there any more guidance around this? Some more documentation would be great. Struggling to remap a topic from another launch file (nav2) from my master bringup launch file.

Comment by shonigmann on 2022-07-18:
The only documentation I know if is directly in the source code: https://github.com/ros2/launch_ros/blob/rolling/launch_ros/launch_ros/actions/set_remap.py#L32-L54

The only example I know if is in a node composition unit test: https://github.com/ros2/launch_ros/blob/master/test_launch_ros/test/test_launch_ros/actions/test_load_composable_nodes.py#L458-L469

nav2_bringup has a similar usecase, where they use PushRosNamespace within a GroupAction instead of SetRemap, but the usage is very similar, if you want a more "in the wild" example: https://github.com/ros-planning/navigation2/blob/e9c4f7827a7a36763150cf7b8ca892e65cdea1c8/nav2_system_tests/src/system/test_multi_robot_launch.py#L96-L110

If you still need guidance, I think you'll need to add a bit more context on what specifically you are having issues with, and it may merit opening a new question.

Comment by jorgemia on 2022-07-19:
Thanks @shonigmann I found an exact example of what I was trying to do here: https://github.com/gnaur/simbot/blob/4d9bb003f10e0570d3ecbdd4298c5f1e63f33130/simbot_node/launch/simbot.launch.py#L89-L107

It follows what you mentioned in your original answer :)

Launching nav2 from another launch file and remapping the cmd_vel topic:

# launch nav 2
nav_include = GroupAction(


             PythonLaunchDescriptionSource(nav_pkg_path + '/launch/bringup_launch.py'),
             launch_arguments = {
                   'use_sim_time' : use_sim,
                   'map' : map_file_name,
                   'autostart' : 'true',
                   'slam' : do_mapping,
                   'params_file' : [configured_params]



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.