0
$\begingroup$

Rosanswers logo

Hello, I am trying to understand if it is possible to record only a specific time window (from Time T1 to time T2) in a rosbag. The reason for this is that I need to print the result of specific topics into 2 different .csv files. According to the rosbag official documentation is possible to start recording from a specific point in time in the bag, and in fact that is what I am doing, but don't know how to set an end time:

<node pkg="rosbag" type="play" name="player" output="screen" args="--clock -q -s 2340 /home/toMyBag/test.bag"/>
<node pkg="rosbag" type="record" name="record" output="screen" args="-O filter_second_order_bis /estimate "/>
<node pkg="rosbag" type="record" name="record" output="screen" args="-O filter_second_order_bis /particle_cloud "/>

But is it possible to set a limit in the time recording?

From the example below, I need to record from approximately minute 39 to minute 224 (4h 4' 0" )approximately so:

Beginning of the recording : 39*60 = 2340 seconds

End of the recording: 224*60 = 13440 second

1

Thank for pointing in the right direction on this matter.


Originally posted by RayROS on ROS Answers with karma: 108 on 2019-06-29

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You can specify a maximum duration for recording a rosbag using the --duration parameter as below:

rosbag record --duration=5m

In your case you could use a duration of 175m to achieve what you need. It's a bit clunky to have to specify the start time in the playback node and the duration in the recording node, but it will do the job.

You can also make the recording rosbag node required="true" so it shuts the whole launch file down automatically when it finishes.

Hope this helps.


Originally posted by PeteBlackerThe3rd with karma: 9529 on 2019-06-29

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by RayROS on 2019-06-29:
@PeteBlackerThe3rd, thanks for reading my question. Yes that helps a lot. I think you are suggesting to do this: <node pkg="rosbag" type="play" name="player" output="screen" required="true" args="--clock --duration=13440 -q -s 2340 /home/emanuele/test.bag"/> I am not sure what you mean with 175m

Comment by RayROS on 2019-06-29:
Ok I know what you mean: <node pkg="rosbag" type="play" name="player" output="screen" args="--clock --duration=185m -q -s 2340 /home/emanuele/test.bag"/> Got it thanks! :)

Comment by PeteBlackerThe3rd on 2019-06-29:
The duration parameter needs to go into the recording rosbag, not the playing one.

Comment by RayROS on 2019-06-29:
Thanks! I am posting below the complete answer if anyone needs:

The following instruction will start the bag from second (in my case) 2340 or (39 min) <node pkg="rosbag" type="play" name="player" output="screen" args="--clock -q -s 2340 /home/toYourBag/test.bag" /> The following instead will record the bag from the minute provided in the play for (in my case) 185 minutes <node pkg="rosbag" type="record" name="record" output="screen" args="--duration=185m -O filter_second_order_bis /estimate /particle_cloud " required ="true"/>

Comment by santK on 2021-10-28:
@RayROS this is for csv file? How can we implement this in cpp file?

Comment by RayROS on 2021-11-11:
@santK, what do you mean?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.