Go to the documentation of this file.00001 import numpy
00002 import tf
00003 import geometry_msgs
00004
00005 from geometry_msgs.msg import Pose, PoseStamped, Transform, TransformStamped
00006
00007
00008 def homogeneous_product_pose_transform(pose, transform):
00009 """
00010 pose should be Pose() msg
00011 transform is Transform()
00012 """
00013
00014 Ht = tf.transformations.quaternion_matrix([transform.rotation.x, transform.rotation.y,
00015 transform.rotation.z, transform.rotation.w])
00016
00017 Tt = [transform.translation.x, transform.translation.y, transform.translation.z]
00018
00019 Ht[:3,3] = Tt
00020
00021
00022 H0 = tf.transformations.quaternion_matrix([pose.orientation.x, pose.orientation.y,
00023 pose.orientation.z, pose.orientation.w])
00024
00025 T0 = [pose.position.x, pose.position.y, pose.position.z]
00026 H0[:3,3] = T0
00027
00028 H1 = numpy.dot(H0, Ht)
00029
00030
00031 result_position = H1[:3,3].T
00032 result_position = geometry_msgs.msg.Vector3(result_position[0], result_position[1], result_position[2])
00033 result_quat = tf.transformations.quaternion_from_matrix(H1)
00034 result_quat = geometry_msgs.msg.Quaternion(result_quat[0], result_quat[1], result_quat[2], result_quat[3])
00035 result_pose = Pose()
00036 result_pose.position = result_position
00037 result_pose.orientation = result_quat
00038 return result_pose