Save automatically rosbag after a certain interval
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.
Asked by pcampolucci on 2019-10-06 18:58:57 UTC
Answers
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"
).
Asked by pavel92 on 2019-10-07 03:01:27 UTC
Comments
Also, there is the rosbag command line API : http://wiki.ros.org/rosbag/Commandline#record
```
-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
Asked by lmathieu on 2019-10-07 04:04:27 UTC
Nice! It worked! Thank you
Asked by pcampolucci on 2019-10-08 14:28:38 UTC
Im glad it helped! You can mark the answer as correct by clicking the tick mark on the left side above.
Asked by pavel92 on 2019-10-08 16:26:02 UTC
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
Asked by affi on 2021-03-10 06:49:23 UTC
Comments