debug_stamps_to_csv.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import rosbag
3 import rospy
4 import sys
5 import os
6 
7 if len(sys.argv) < 3:
8  print "Usage: {} <bag_name> <debug_info topic>".format(os.path.basename(sys.argv[0]))
9  print "Output: bag_name.csv"
10  exit()
11 
12 input_bag_name = sys.argv[1]
13 
14 try:
15  input_bag = rosbag.Bag(input_bag_name)
16  bag_loaded = True
17 except Exception:
18  print "Could not open bag {}".format(input_bag_name)
19  bag_loaded = False
20 
21 if bag_loaded:
22  name, ext = os.path.splitext(input_bag_name)
23 
24  out_file_name = "{name}.csv".format(name=name)
25  print "Writing to {}".format(out_file_name)
26  out_file = open(out_file_name, 'w')
27 
28  for topic, msg, t in input_bag.read_messages(topics=[sys.argv[2]]):
29  out_file.write('{} {:.12f} {:.12f} {:.12f}\n'.format(msg.seq, msg.ros_time, msg.sensor_time, msg.corrected_timestamp))
30 
31  out_file.close()
32  input_bag.close()


timesync_ros
Author(s): Juraj Oršulić
autogenerated on Mon Jun 10 2019 15:28:33