ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

ros2 launch using IncludeLaunchDescription and remapping topics [closed]

asked 2022-01-25 12:30:48 -0600

jeremya gravatar image

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?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by shonigmann
close date 2022-07-19 11:18:21.590670

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-01-25 13:22:53 -0600

shonigmann gravatar image

updated 2022-01-25 13:24:19 -0600

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

edit flag offensive delete link more

Comments

Yes that should be the way. I implemented it myself not so long ago so if you have troubles let us know.

tnajjar gravatar image tnajjar  ( 2022-01-25 16:27:27 -0600 )edit

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.

jorgemia gravatar image jorgemia  ( 2022-07-18 05:00:14 -0600 )edit

The only documentation I know if is directly in the source code: https://github.com/ros2/launch_ros/bl...

The only example I know if is in a node composition unit test: https://github.com/ros2/launch_ros/bl...

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/navig...

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.

shonigmann gravatar image shonigmann  ( 2022-07-18 11:22:44 -0600 )edit
1

Thanks @shonigmann I found an exact example of what I was trying to do here: https://github.com/gnaur/simbot/blob/...

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(
    actions=[

        SetRemap(src='/cmd_vel',dst='/cmd_vel_nav'),

        IncludeLaunchDescription(
             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]

             }.items(),

        )
    ]
)
jorgemia gravatar image jorgemia  ( 2022-07-19 06:22:52 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2022-01-25 12:30:48 -0600

Seen: 330 times

Last updated: Jan 25 '22