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

Save automatically rosbag after a certain interval

asked 2019-10-06 18:58:57 -0500

pcampolucci gravatar image

Hello everyone, I am editing a .launch file such that it records bags of images from a camera. Now, the camera is pretty unstable so it might disconnect and I would not like to miss a whole 5 min record because of an interference.

In the light of this, I was wandering it there was a way to lets say save a rosbag every 30 sec automatically, so that if i record for 5 minutes I have 10 separated rosbags of that record.

Thank you very much.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-10-07 03:01:27 -0500

pavel92 gravatar image

updated 2019-10-07 03:19:39 -0500

You definitely can but I am not sure if that is the best way to approach this problem. You can take a look at the rosbag API. You can create a timer that opens a bag every 30 sec to record the camera data and closes the previous opened bag.

Another way to tackle this problem is to restart the camera. You will need to check/throw an exception if the camera is disconnected and relaunch the camera node (check the documentation for roslaunch atribute: respawn="true").

edit flag offensive delete link more

Comments

Also, there is the rosbag command line API : http://wiki.ros.org/rosbag/Commandlin...

```

-d, --duration

Specify the maximum duration of the recorded bag file.

$ rosbag record --duration=30 /chatter
$ rosbag record --duration=5m /chatter
$ rosbag record --duration=2h /chatter

```

and :

```

--split

Split the bag when maximum size or duration is reached

$ rosbag record --split --size=1024 /chatter
$ rosbag record --split --duration=30 /chatter
$ rosbag record --split --duration=5m /chatter
$ rosbag record --split --duration=2h /chatter

```

something like :

rosbag record /my_topic --split --duration=30

The rosbag will be split every 30sec, thus creating a new bag file every 30sec

lmathieu gravatar image lmathieu  ( 2019-10-07 04:04:27 -0500 )edit

Nice! It worked! Thank you

pcampolucci gravatar image pcampolucci  ( 2019-10-08 14:28:38 -0500 )edit

Im glad it helped! You can mark the answer as correct by clicking the tick mark on the left side above.

pavel92 gravatar image pavel92  ( 2019-10-08 16:26:02 -0500 )edit

Hey, Can we specify with command to run for 1 hour but split after 10 minutes or when the size of the bag reach some values? So record for 1 hour each 10 minutes and as a result able to get 6 bag files. Is it possible? Something like this https://github.com/ros/ros_comm/issues/4

affi gravatar image affi  ( 2021-03-10 05:49:23 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-10-06 18:58:57 -0500

Seen: 1,206 times

Last updated: Oct 07 '19