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

How to record bagfile within launch file

asked 2017-01-09 04:42:45 -0500

baozhang gravatar image

I would like to record some topics via launch file.


<!-- record topics listed below -->
<arg name="topics_name" default="joint_states /usb_cam/left/image_raw"/>

<!-- record topics -->
<node name="record_topics_for_verification" pkg="rosbag" type="record"
      args="$(arg topics_name)"/>


This code runs without any errors, however, there is no recorded bagfile in current directory.

Does anyone know the reason?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-01-09 05:50:38 -0500

DavidN gravatar image

updated 2017-01-09 05:50:57 -0500

By default, the bag file will be in ~/.ros folder with the name being the date and time of starting recording. For exact name, you can add this flag output="screen" so it looks like this

<node name="record_topics_for_verification" pkg="rosbag" type="record" args="$(arg topics_name)" output="screen"/>

After adding this flag, you will see the bag name in rosout after you launch.

Note: the bag file will have the name of while being recording. Only after you properly terminate the recording node, the file name will be changed to xxx.bag

edit flag offensive delete link more


Thank you for replying.

I found recorded bagfiles in ~/.ros folder.

Do you know how to change the folder to record bagfiles?

baozhang gravatar image baozhang  ( 2017-01-09 21:28:41 -0500 )edit

You can add -o in args list. Follow this:

DavidN gravatar image DavidN  ( 2017-01-09 21:48:24 -0500 )edit

Thank you for your kindness. My question was solved!

baozhang gravatar image baozhang  ( 2017-01-10 09:18:50 -0500 )edit

Question Tools

1 follower


Asked: 2017-01-09 04:42:45 -0500

Seen: 3,331 times

Last updated: Jan 09 '17