SHARE
TWEET

Untitled

a guest Mar 26th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import rosbag
  2. import sys
  3. import os
  4. from tf.msg import tfMessage
  5.  
  6. if len(sys.argv) < 1:
  7.     print 'Usage example: tum_rename_world_kinect_frame.py rgbd_dataset_freiburg3_long_office_household.bag'
  8.     exit
  9.  
  10. os.rename(sys.argv[1], sys.argv[1] + '.tmp')
  11. with rosbag.Bag(sys.argv[1], 'w') as outbag:
  12.     for topic, msg, t in rosbag.Bag(sys.argv[1] + '.tmp').read_messages():
  13.         if topic == "/tf" and msg.transforms:
  14.             newList = [];
  15.             for m in msg.transforms:
  16.                 if m.header.frame_id == "/world":
  17.                     print 'Renamed /world->' + m.child_frame_id + ' to /world->' + m.child_frame_id + '_gt'
  18.                     m.child_frame_id = m.child_frame_id + '_gt'
  19.                 newList.append(m)
  20.             if len(newList)>0:
  21.                 msg.transforms = newList
  22.                 outbag.write(topic, msg, t)
  23.         else:
  24.             outbag.write(topic, msg, t)
  25. os.remove(sys.argv[1] + '.tmp')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top