ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Hello together,
I fixed it and now it feels way to easy. But I will leave the solution here anyway. Maybe it helps the next person starting with tf's.
The running code: first node:
import rospy import tf
class tf_firsttry_pub_class():
def __init__(self):
rospy.init_node('tf_firsttry_pub')
now = rospy.Time.now()
br = tf.TransformBroadcaster()
R = rospy.Rate(150)
while not rospy.is_shutdown():
br.sendTransform((1, 1, 1), (0, 0, 0, 1), rospy.Time(), 'One','base_link')
R.sleep()
if __name__ == '__main__': try: tf_firsttry_pub_class() except rospy.ROSInterruptException: pass
second node:
import rospy import tf
class tf_firsttry_listen_class(): def __init__(self): rospy.init_node('tf_firsttry_listen') listener = tf.TransformListener() now = rospy.Time.now() while not rospy.is_shutdown(): listener.waitForTransform('/base_link','/One',rospy.Time(), rospy.Duration(4.0)) (trans, rot) = listener.lookupTransform('/base_link', '/One', rospy.Time(0)) print trans
if __name__ == '__main__': try: tf_firsttry_listen_class() except rospy.ROSInterruptException: pass
Note the R = rospy.Rate(150) and R.sleep() in the first code and the listener.waitForTransform in the second!
2 | No.2 Revision |
Hello together,
I fixed it and now it feels way to easy. But I will leave the solution here anyway. Maybe it helps the next person starting with tf's.
The running code: first node:
#!/usr/bin/env python
import rospy
import second node:
#!/usr/bin/env python
import rospy
import Note the R =
rospy.Rate(150) rospy.Rate(150) and R.sleep() R.sleep()
in the first code and the listener.waitForTransform listener.waitForTransform
in the second!