Created
February 8, 2019 10:52
-
-
Save ojura/2913c6bf9c0dc42345f31fd7c0b6b0f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rosbag | |
import os | |
import sys | |
def remove_tf(inbag,outbag,frame_ids): | |
rospy.loginfo(' Processing input bagfile: %s', inbag) | |
rospy.loginfo(' Writing to output bagfile: %s', outbag) | |
rospy.loginfo(' Removing frame_ids: %s', ' '.join(frame_ids)) | |
outbag = rosbag.Bag(outbag,'w') | |
for topic, msg, t in rosbag.Bag(inbag,'r').read_messages(): | |
if topic == "/tf": | |
new_transforms = [] | |
for transform in msg.transforms: | |
if transform.child_frame_id not in frame_ids: | |
new_transforms.append(transform) | |
msg.transforms = new_transforms | |
outbag.write(topic, msg, t) | |
rospy.loginfo('Closing output bagfile and exit...') | |
outbag.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment