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

[ROS2] Start rosbag2 recording from launch file

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

tlaci gravatar image

Hi,

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
3

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

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([
        launch.actions.ExecuteProcess(
            cmd=['ros2', 'bag', 'record', '-a'],
            output='screen'
        )
    ])

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

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

Comments

1

Is anyone else experiencing an issue with this? When I ctrl-c the launch bag always dies.

The launch file:

def generate_launch_description():
    return LaunchDescription([
    ExecuteProcess(cmd=['ros2', 'bag', 'record', '-a'], output='screen', log_cmd=True),
])

On ctrl-c:

[ERROR] [ros2-2]: process has died [pid 40507, exit code 2, cmd 'ros2 bag record -a'].

And the tables in the sqlite database seem corrupt.

justinberi gravatar image justinberi  ( 2021-05-25 18:54:57 -0500 )edit

@justinberi I think that better place to ask for it would be a GitHub issue there: https://github.com/ros2/rosbag2 You can prepare your MWE and error description etc. and maybe get answers directly from maintainers

ljaniec gravatar image ljaniec  ( 2022-03-25 06:46:52 -0500 )edit

Question Tools

2 followers

Stats

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

Seen: 3,386 times

Last updated: Jan 17 '20