Skip to content

Instantly share code, notes, and snippets.

@matlabbe
Created August 8, 2016 14:43
Show Gist options
  • Save matlabbe/477901e5b7c3d00a0f5aee2f3d78c155 to your computer and use it in GitHub Desktop.
Save matlabbe/477901e5b7c3d00a0f5aee2f3d78c155 to your computer and use it in GitHub Desktop.
import rosbag
from tf.msg import tfMessage
with rosbag.Bag('output.bag', 'w') as outbag:
for topic, msg, t in rosbag.Bag('input.bag').read_messages():
if topic == "/tf" and msg.transforms:
newList = [];
for m in msg.transforms:
if m.header.frame_id != "map":
newList.append(m)
else:
print 'map frame removed!'
if len(newList)>0:
msg.transforms = newList
outbag.write(topic, 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