9 print "Usage: {} <bag_name> <parent frame> <child frame>".format(os.path.basename(sys.argv[0]))
10 print "Output file: bag_name.csv - each line: <stamp> <yaw angle>" 13 input_bag_name = sys.argv[1]
14 parent_frame = sys.argv[2]
15 child_frame = sys.argv[3]
21 print "Could not open bag {}".format(input_bag_name)
25 name, ext = os.path.splitext(input_bag_name)
27 out_file_name =
"{name}.csv".format(name=name)
28 print "Writing to {}".format(out_file_name)
29 out_file = open(out_file_name,
'w')
32 for topic, msg, t
in input_bag.read_messages(topics=[
'tf']):
33 for t
in msg.transforms:
34 if t.header.frame_id == parent_frame
and t.child_frame_id == child_frame:
36 quat = PyKDL.Rotation.Quaternion(*[ getattr(t.transform.rotation, i)
for i
in [
'x',
'y',
'z',
'w'] ])
37 yaw = quat.GetRPY()[2]
38 out_file.write(
'{:.12f} {:.12f}\n'.format(t.header.stamp.to_sec(), yaw))
42 print(
"Wrote {} entries.".format(counter))