How to set up launch arguments for multiple topics in ros2 bag record?

asked 2021-02-24 15:51:58 -0500

khaiyichin gravatar image

updated 2021-02-24 15:52:29 -0500

Initially posted as a GitHub issue, but was directed here.

System

  • OS: Ubuntu Focal
  • ROS 2 Distro: Foxy

Description

Essentially I'm trying to create a launch file that allows the user to specify the topics as arguments to the launch file.

To Reproduce

Minimum example:

# rosbag_record.launch.py
launch_arg_rosbag_topics = DeclareLaunchArgument('topics', default_value='-a')

process_rosbag_record = ExecuteProcess(
      cmd=['ros2', 'bag', 'record', LaunchConfiguration('topics')],
)

return LaunchDescription([
    launch_arg_rosbag_topics,
    process_rosbag_record
])

In the terminal:

# terminal
$ ros2 launch ./rosbag_record.launch.py topics:='/cmd_vel /odom /odom_gt /velodyne_points /tf /tf_static'

gives the following error:

[ros2-1] [ERROR] [1614037748.512620668] [rosbag2_transport]: Failed to expand topic name /cmd_vel /odom /odom_gt /velodyne_points /tf /tf_static with error: topic name is invalid, at /tmp/binarydeb/ros-foxy-rcl-1.1.10/src/rcl/expand_topic_name.c:73

And after killing it I get the following message, which seems to indicate that the evaluated command should be correct, and I was able to verify by copy and pasting it (i.e., ros2 bag record /cmd_vel /odom /odom_gt /velodyne_points /tf /tf_static).

[ERROR] [ros2-1]: process has died [pid 257759, exit code 2, cmd 'ros2 bag record /cmd_vel /odom /odom_gt /velodyne_points /tf /tf_static'].
edit retag flag offensive close merge delete