Ask Your Question

Rosbag in Roslaunch, save rosbag to specific directory

asked 2016-10-12 08:59:27 -0500

jtim gravatar image

updated 2016-10-13 02:40:58 -0500

Hey I wanted to use robsbag record in a roslaunch file like:

<node pkg="rosbag" type="record" name="record" output="screen"/>

How do I specify that I want to save the bag with a timestamp and to a specific location?

I am running on an embedded hardware and have therefore installed the needed ros packages for perception: ros-indigo-perception and ros-indigo-rosbag. Do I need any other packages?

I can run Rosbags without any issue, but start recording keeps failing. Running the following from the commandline, instead of launch file, achieves what I want:

rosbag record -o ~/../../media/ubuntu/E04E-7229/Rosbag/ -a

But running the command in the roslaunch file:

<node pkg="rosbag" type="record" name="record" output="screen" args="-o ~/../../media/ubuntu/E04E-7229/Rosbag/ -a" launch-prefix="xterm -e"/>

makes it crash with Error opening file! I tried changing the write rights for the launch file, but the error persists

Error writing: Error opening file: ~/Desktop/

The error was apparently now does not exist when writing to the Desktop but only when I write to the SD-Card. Nevertheless the .bag is not created when I use launch file. If I do the same thing in the terminal the file is created and no errors >/

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-10-12 09:15:49 -0500

mgruhler gravatar image

updated 2016-10-13 02:52:23 -0500

you can use the args flag to pass in the arguments as you would from the command line:

<node pkg="rosbag" type="record" args="-O <PATH_TO_BAGFILE>" name="record" output="screen"/>


Even though this is probably not the way it is intended, you could also go with the prefix (note, lower case o):

<node pkg="rosbag" type="record" args="-o <PATH_TO_BAGFILE>" name="record" output="screen"/>

e.g. -o ~/Desktop/ would result in the file /home/mig/Desktop/_2016-10-12-17-06-59.bag on my system. But this is rather a workaround then a proper solution.


whoops, soory about that. Seems like the ~ shortcut for the users home directory cannot be resolved from the launch file. So you need to specify the full path, i.e. /home/<USER>/... for it to work.

edit flag offensive delete link more


hmm, cannot seem to get it to work, I try to access a folder on a SD-Card, where there is write access. So I did: <node pkg="rosbag" type="record" name="record" output="screen" args="-O /media/ubuntu/E04E-7229/Rosbag/"/> but cannot see any output.

jtim gravatar image jtim  ( 2016-10-12 09:26:04 -0500 )edit

@mig Do I need to specify the name of the file? I would rather have that it is generated based on a timestamp, is this possible?

jtim gravatar image jtim  ( 2016-10-12 09:31:53 -0500 )edit

yes, you need to specify the filename with -O. For an alternative, see edit above.

mgruhler gravatar image mgruhler  ( 2016-10-12 10:08:44 -0500 )edit

Weird I cannot seem to get it to work: [ccamera/record-2] process has died [pid 26717, exit code 1, cmd /opt/ros/indigo/lib/rosbag/record -o ~/Desktop/ __name:=record __log:=/root/.ros/log/6c14908a-9087-11e6-ad7f-00044b5ab358/ccamera-record-2.log]. The logfile is not created either.

jtim gravatar image jtim  ( 2016-10-13 01:33:27 -0500 )edit

whoops, soory about that. Seems like the ~ cannot be resolved here. So you need to specify the full path, i.e. /home/<USER>/... for it to work.

mgruhler gravatar image mgruhler  ( 2016-10-13 02:26:38 -0500 )edit

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: 2016-10-12 08:59:27 -0500

Seen: 4,703 times

Last updated: Oct 13 '16