sync_bagfile.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # Script to synchronize the timings in a recorded bagfile, so that it can be 
00004 # played back in sync with the timestamps of the recorded data. Useful for 
00005 # fixing a "jerky" or asynchronuous visalization in RViz e.g. when recorded 
00006 # over wireless
00007 
00008 # See http://code.ros.org/lurker/message/20100901.154936.67720d20.en.html#ros-users
00009 # and http://www.ros.org/wiki/rosbag/Cookbook
00010 
00011 import roslib; roslib.load_manifest('rosbag')
00012 import sys, rosbag
00013 outbag = rosbag.Bag(sys.argv[2], 'w')
00014 try:
00015     for topic, msg, t in rosbag.Bag(sys.argv[1]).read_messages():
00016         if topic == "/tf":
00017             outbag.write(topic, msg, msg.transforms[0].header.stamp)
00018             
00019         elif not topic == "/rosout":
00020             outbag.write(topic, msg, msg.header.stamp if msg._has_header else t)
00021 finally:
00022     outbag.close()
00023                 


fr_tools
Author(s): Armin Hornung, Daniel Maier
autogenerated on Mon Oct 6 2014 00:08:21