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

Possible to record a specific time window (from T1 to T2) of a rosbag?

asked 2019-06-29 11:31:48 -0600

RayROS gravatar image

updated 2019-06-29 11:37:48 -0600

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-06-29 12:42:12 -0600

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.

edit flag offensive delete link more

Comments

@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

RayROS gravatar image RayROS  ( 2019-06-29 14:29:10 -0600 )edit

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! :)

RayROS gravatar image RayROS  ( 2019-06-29 15:27:10 -0600 )edit

The duration parameter needs to go into the recording rosbag, not the playing one.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-06-29 15:51:14 -0600 )edit

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"/>

RayROS gravatar image RayROS  ( 2019-06-29 16:23:02 -0600 )edit

@RayROS this is for csv file? How can we implement this in cpp file?

santK gravatar image santK  ( 2021-10-28 21:04:14 -0600 )edit

@santK, what do you mean?

RayROS gravatar image RayROS  ( 2021-11-11 15:32:04 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2019-06-29 11:31:48 -0600

Seen: 2,578 times

Last updated: Jun 29 '19