rosbag2 icon indicating copy to clipboard operation
rosbag2 copied to clipboard

Play: start and end time

Open dongfang-steven-yang opened this issue 3 years ago • 5 comments

Description

Hello,

I just wonder if ros2 bag play has functionality like -s as in rosbag play in ROS 1? I would like to debug my algorithm at a specific time in a big bag file. For example, the duration of my bag is 10 mins, when I start to replay the topics, I would like to directly jump into 6 mins, so that every time I open a bag, I don't have to wait.

If there is no such functionality, is there any plan to add it? Or is there any workaround to solve this issue?

Thanks, DF

dongfang-steven-yang avatar Dec 03 '21 09:12 dongfang-steven-yang

I don't think the start/stop timestamp feature is exposed in the CLI tool yet, but the infrastructure exists following the work in https://github.com/ros2/rosbag2/issues/696 and https://github.com/ros2/rosbag2/issues/821.

aprotyas avatar Dec 03 '21 10:12 aprotyas

Implementation question for maintainers: For the play start timestamp, can this feature boil down to adding a start timestamp to rosbag2_py.PlayOptions, which can then be used to invoke Player::seek(timepoint) after construction of a Player but before calling Player::play() on it? So, right after L115 here.

https://github.com/ros2/rosbag2/blob/2abc50904803a0eae58ee2094542977ec9262db7/rosbag2_py/src/rosbag2_py/_transport.cpp#L109-L128

Edit: In hindsight, this may not work because rosbag2_transport::Player seems to maintain a _starting_time from the reader metadata.

aprotyas avatar Dec 03 '21 10:12 aprotyas

These both make sense as additional PlayOption fields.

For starting time, it should be easy to implement by overriding Player::starting_time_ in Player::play.

The end time could be implemented in the dequeueing mechanism by returning nullptr from Player::peek_next_message_from_queue, which would stop playback at that time. Alternatively, it could be implemented in the enqueueing mechanism Player::enqueue_up_to_boundary, stopping enqueueing when a message past the given timestamp is reached. The result would be approximately the same - maybe slightly better performance to stop enqueueing messages, instead of adding messages to the queue that we don't intend to read.

emersonknapp avatar Dec 03 '21 21:12 emersonknapp

We have a PR in our fork that adds "play until timestamp" functionality. We're planning on upstreaming it later this week or early next week. It might need some revision though.

gbiggs avatar Dec 06 '21 03:12 gbiggs

We have [a PR in our fork[(https://github.com/gbiggs/pull/5) that adds "play until timestamp" functionality. We're planning on upstreaming it later this week or early next week. It might need some revision though.

~Oops, I didn't realize there was WIP on this. Feel free to close my PR to reduce the noise.~ I misread your comment, but https://github.com/gbiggs/rosbag2/pull/5 and https://github.com/ros2/rosbag2/pull/931 should cover both use-cases here. Nice!

aprotyas avatar Dec 06 '21 04:12 aprotyas

  • Closing as done. Since --start-offset CLI parameter was added in https://github.com/ros2/rosbag2/pull/931

MichaelOrlov avatar Feb 01 '23 03:02 MichaelOrlov