dump_mocap.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 from geometry_msgs.msg import PoseStamped
5 from tf.transformations import *
6 import os
7 import tf
8 
9 initial_pose = None
10 world_pose = None
11 def poseMsgToMatrix(pose):
12  return concatenate_matrices(translation_matrix([pose.position.x,
13  pose.position.y,
14  pose.position.z]),
15  quaternion_matrix([pose.orientation.x,
16  pose.orientation.y,
17  pose.orientation.z,
18  pose.orientation.w]))
19 
20 
21 
22 
23 def callback(msg):
24  global f, initial_pose, world_pose
25  if world_pose == None:
26  rospy.loginfo("calibrating world coordinates")
27  A = identity_matrix()
28  B = poseMsgToMatrix(msg.pose)
29  C = concatenate_matrices(A, inverse_matrix(B))
30  world_pose = C
31  # x, y, z, qx, qy, qz, qw
32  pose = poseMsgToMatrix(msg.pose)
33  new_A = concatenate_matrices(world_pose, pose)
34  diff = new_A
35  diff_pos = translation_from_matrix(diff)
36  diff_rot = quaternion_from_matrix(diff)
37  f.write("%f, %f, %f, %f, %f, %f, %f\n" % (diff_pos[0], diff_pos[1],
38  diff_pos[2],
39  diff_rot[0],
40  diff_rot[1],
41  diff_rot[2],
42  diff_rot[3]))
43 
44 if __name__ == "__main__":
45  rospy.init_node("dump_mocap")
46  file_name = rospy.get_param("~file_name", "output.csv")
47  tf_listener = tf.TransformListener()
48  try:
49  f = open(file_name, "w")
50  sub = rospy.Subscriber("/Robot_1/pose", PoseStamped, callback)
51  rospy.spin()
52  finally:
53  f.close()
54 
55 
56 
def callback(msg)
Definition: dump_mocap.py:23
def poseMsgToMatrix(pose)
Definition: dump_mocap.py:11


jsk_footstep_controller
Author(s):
autogenerated on Fri May 14 2021 02:52:04