Ask Your Question

[ROS2] Start rosbag2 recording from launch file

asked 2020-01-14 10:15:04 -0600

tlaci gravatar image


With the

ros2 bag record

command I can easily start recording data to a bag file. Is it possible the start recording in with a launch file? I would like to start some nodes from this launch file and start recording, as well.

Thanks for your help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-01-17 11:48:03 -0600

jacobperron gravatar image

You should be able to launch the ros2 bag record command as an executable. For example, recording all topics:

import launch

def generate_launch_description():
    return launch.LaunchDescription([
            cmd=['ros2', 'bag', 'record', '-a'],

and the XML equivalent if you are using ROS Eloquent or newer:

  <executable cmd="ros2 bag record -a" output="screen" />
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-01-14 10:15:04 -0600

Seen: 35 times

Last updated: Jan 17