convert-rosbag.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 import roslib; roslib.load_manifest('rosbag')
00004 import rosbag
00005 
00006 import sys
00007 
00008 del sys.argv[0]
00009 robot_namespace = '/clearpath/robots/default'
00010 
00011 if len(sys.argv) < 1:
00012     print "Usage: ./convert-rosbag.py log1.bag log2.bag"
00013     print "       ./convert-rosbag.py *.bag"
00014     print ""
00015     print "Edit the script to adjust topics and fields to output as csv."
00016 
00017 for filename in sys.argv: 
00018     print "Extracting from %s" % filename
00019     bag = rosbag.Bag(filename)
00020     with open(filename + '.mag.csv', 'w') as outfile:
00021         outfile.write("x,y,z\n")
00022 
00023         for topic, msg, t in bag.read_messages(topics=[robot_namespace + '/raw_mag']):
00024             fields = [msg.x,msg.y,msg.z]
00025             outfile.write(','.join([str(f) for f in fields]))
00026             outfile.write('\n')
00027 
00028     bag.close()


clearpath_sensors
Author(s): Ryan Gariepy
autogenerated on Sun Oct 5 2014 22:52:23