nivir
12/23/2017 - 8:06 PM

rewrite-rosbag.py

#!/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)