ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ros2 bag topic remapping from launch file

asked 2023-08-08 09:20:11 -0500

updated 2023-08-08 13:56:46 -0500

Hi,

I'm trying to run the following command from a launch file:

some_remap = '/namespace/rgb/camera_info:=/namespace_test/rgb/camera_info'
remap = f'--remap {some_remap}'
ld = LaunchDescription(
    [
        ExecuteProcess(
            cmd=['ros2', 'bag', 'play', str(rosbag_file), remap],
            output='screen'
        ),
        ReadyToTest(),
    ]

This results in the following command:

ros2 bag play /.../rosbag.db3 --remap /namespace/rgb/camera_info:=/namespace_test/rgb/camera_info

For some reason Ros2 complains about unrecognized arguments:

ros2: error: unrecognized arguments: --remap /namespace/rgb/camera_info:=/namespace_test/rgb/camera_info

But according to this answer and ros2 bag play -h the above command should work. Without the remapping things work fine. So what's wrong here?

And if I copy-paste the resulting command directly into the terminal it works fine...

Thanks in advance!

(Ros2 Humble on Ubuntu 22.04)

edit retag flag offensive close merge delete

Comments

It works for my case. maybe you try to update your rosbag2 version?

sudo apt-get install ros-humble-rosbag2
BCJ gravatar image BCJ  ( 2023-08-08 09:34:35 -0500 )edit

Sorry updating makes no difference.

oddbotwl gravatar image oddbotwl  ( 2023-08-08 09:42:17 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2023-08-08 13:52:24 -0500

Ok so it should be:

remap = '<old_topic>:=<new_topic>'
LaunchDescription(
    [
        ExecuteProcess(
            cmd=['ros2', 'bag', 'play', rosbag_file, '--remap', remap],
            output='screen'
        ),
        ReadyToTest(),
    ]

And for multiple remaps:

remap1 = '<old_topic>:=<new_topic>'
remap2 = '<old_topic>:=<new_topic>'
LaunchDescription(
    [
        ExecuteProcess(
            cmd=['ros2', 'bag', 'play', rosbag_file, '--remap', remap1, remap2],
            output='screen'
        ),
        ReadyToTest(),
    ]
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-08-08 09:20:11 -0500

Seen: 365 times

Last updated: Aug 08 '23