Skip to content

Instantly share code, notes, and snippets.

@janpaul123
Created January 7, 2020 23:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janpaul123/deaa92338d5e8309ef7aa7a55d625152 to your computer and use it in GitHub Desktop.
Save janpaul123/deaa92338d5e8309ef7aa7a55d625152 to your computer and use it in GitHub Desktop.
Read an "input.bag" ROS bag with messages stored in arbitrary order, and write to "output.bag" ordered by receive time (required by Webviz to read)
import rosbag
with rosbag.Bag('output.bag', 'w') as outbag:
for topic, msg, t in rosbag.Bag('input.bag').read_messages():
outbag.write(topic, msg, t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment