[ros-users] [Discourse.ros.org] [General] Timestamps and rosbags: discussing an alternative to clock and use_sim_time

P. J. Reed ros.discourse at gmail.com
Mon Nov 27 14:45:34 UTC 2017



The problem you're encountering is because `rosbag play` plays back messages in the order they were recorded in the bag file, but that is not necessarily the same as the chronological order of their timestamps nor the order they were broadcast in.  Due to that, some messages can get replayed out of order compared to TFs that they relied upon.

I don't think it'd be useful to make `rosbag play` change the header/stamp of messages; messages will still get played back in the wrong order, and you will be guaranteed to get different behavior from your system than was originally observed.  Playing back bag files based on the order of message timestamps would be more useful, but also fairly difficult to do correctly due to how rosbags are structured.

The commonly accepted solution is to simply do a bit of post-processing on recorded bag files and reorder them so that messages are ordered based on their timestamps.  There is an example snippet of Python code in the [rosbag Cookbook](http://wiki.ros.org/rosbag/Cookbook) that shows how to do that.

Edit: Oops, the example I was thinking of involves rewriting header timestamps, not reordering messages.  I'll see if I can find the code for that...





---
[Visit Topic](https://discourse.ros.org/t/timestamps-and-rosbags-discussing-an-alternative-to-clock-and-use-sim-time/3238/7) or reply to this email to respond.




More information about the ros-users mailing list