Skip to content

Instantly share code, notes, and snippets.

@nivir
Forked from mintar/rewrite-rosbag.py
Created December 23, 2017 20:06
Show Gist options
  • Save nivir/98cceef5c836c0183b87a8a46cb9a75a to your computer and use it in GitHub Desktop.
Save nivir/98cceef5c836c0183b87a8a46cb9a75a to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import rosbag
import sys
inbag_name = sys.argv[1]
outbag_name = inbag_name.replace('.bag', '-fixed.bag')
with rosbag.Bag(outbag_name, 'w') as outbag:
for topic, msg, t in rosbag.Bag(inbag_name).read_messages():
if topic == "/camera/depth_registered/points_drop" and msg.header.frame_id:
msg.header.frame_id = "/kinect_rgb_optical_frame"
outbag.write("/kinect/depth_registered/points_drop", msg, t)
else:
outbag.write(topic, msg, t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment