Skip to content

Instantly share code, notes, and snippets.

@jokla
Last active August 8, 2016 09:10
Show Gist options
  • Save jokla/2630f8dbbd4391d91ab28b2f3f76801a to your computer and use it in GitHub Desktop.
Save jokla/2630f8dbbd4391d91ab28b2f3f76801a to your computer and use it in GitHub Desktop.
How to compute frame transformations with Tf (ROS)
import rospy
import math
import tf
if __name__ == '__main__':
rospy.init_node('look_up_pepper_tf')
listener = tf.TransformListener()
trans = []
rot = []
rate = rospy.Rate(10.0)
while not trans:
try:
(trans,rot) = listener.lookupTransform('/base_footprint', '/CameraTop_optical_frame', rospy.Time(0))
except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):
continue
rate.sleep()
print 'Translation: ' , trans
print 'Rotation: ' , rot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment