tf_to_pose.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 import tf
5 from geometry_msgs.msg import PoseStamped
6 
7 
8 def cb(event):
9  stamp = rospy.Time.now()
10  try:
11  listener.waitForTransform(src_frame, dst_frame, stamp,
12  timeout=rospy.Duration(1))
13  except Exception, e:
14  rospy.logerr(e)
15  return
16 
17  dst_pose = listener.lookupTransform(src_frame, dst_frame, stamp)
18 
19  pose_msg = PoseStamped()
20  pose_msg.header.frame_id = src_frame
21  pose_msg.header.stamp = stamp
22  pose_msg.pose.position.x = dst_pose[0][0]
23  pose_msg.pose.position.y = dst_pose[0][1]
24  pose_msg.pose.position.z = dst_pose[0][2]
25  pose_msg.pose.orientation.x = dst_pose[1][0]
26  pose_msg.pose.orientation.y = dst_pose[1][1]
27  pose_msg.pose.orientation.z = dst_pose[1][2]
28  pose_msg.pose.orientation.w = dst_pose[1][3]
29 
30  pub.publish(pose_msg)
31 
32 
33 if __name__ == '__main__':
34  rospy.init_node('tf_to_pose')
35  pub = rospy.Publisher('~output', PoseStamped, queue_size=1)
36  src_frame = rospy.get_param('~src_frame')
37  dst_frame = rospy.get_param('~dst_frame')
38  rate = rospy.get_param('~rate', 1.)
39  timer = rospy.Timer(rospy.Duration(1.0 / rate), cb)
40  listener = tf.TransformListener()
41  rospy.spin()
def cb(event)
Definition: tf_to_pose.py:8


jsk_topic_tools
Author(s): Kei Okada , Yusuke Furuta
autogenerated on Tue Feb 6 2018 03:45:19