Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set up launch arguments for multiple topics? #665

Closed
khaiyichin opened this issue Feb 23, 2021 · 2 comments
Closed

How to set up launch arguments for multiple topics? #665

khaiyichin opened this issue Feb 23, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@khaiyichin
Copy link

khaiyichin commented Feb 23, 2021

Description

This is more of a question, but I couldn't seem to find any pointers on how to do it. Essentially I'm trying to create a launch file that allows the user to specify the topics as arguments to the launch file. I wasn't sure if this was a launch question, but I figured it might be helpful to have a rosbag2 targeted answer.

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'].

System (please complete the following information)

  • OS: Ubuntu Focal
  • ROS 2 Distro: Foxy
@khaiyichin khaiyichin added the bug Something isn't working label Feb 23, 2021
@emersonknapp
Copy link
Collaborator

emersonknapp commented Feb 23, 2021

This question may be better suited to ROS Answers

@emersonknapp
Copy link
Collaborator

To add some more context on this - the commandline is being interpreted as a request to record a single topic named "/cmd_vel /odom /odom_gt /velodyne_points /tf /tf_static" - which is not a valid topic name because it contains spaces. The ExecuteProcess args need to be a list. This is described in ros2/launch#263

Until that issue is solved, you can solve this using shell=True as is described in the above issue. E.g.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import ExecuteProcess
from launch.substitutions import LaunchConfiguration

def generate_launch_description():
    return LaunchDescription([
        DeclareLaunchArgument('topics', default_value=['-a'], description='Topics to record'),
        ExecuteProcess(cmd=['ros2', 'bag', 'record', LaunchConfiguration('topics')], shell=True),
    ])

I'll close this issue given there is nothing to do in rosbag2 for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants