0
$\begingroup$

Rosanswers logo

Is there a working example of the tf2 listener under hydro. I have tried to follow tutorials on the wiki but they seems to be outdated.

Just to check if I follow the tutorial right. I have a simple example of tf:

#!/usr/bin/env python

import roslib; roslib.load_manifest('cvut_sandbox')
import rospy
import tf

if __name__ == '__main__':
    rospy.init_node("test_tf_listener")
    tfl = tf.TransformListener()
    (trans, rot) = tfl.waitForTransform('r1_link_1', 'r2_link_2', rospy.Time(0), rospy.Duration(0))

This will fail under hydro due to bug reported here but works under groovy. Trying to follow the tutorial I ended up with version for tf2:

#!/usr/bin/env python

import roslib; roslib.load_manifest('cvut_sandbox')
import rospy
import tf2_ros

if __name__ == '__main__':
    rospy.init_node("test_tf_listener")
    buffer = tf2_ros.Buffer()
    tfl = tf2_ros.TransformListener(buffer)
    (trans, rot) = tfl.waitForTransform('r1_link_1', 'r2_link_2', rospy.Time(0), rospy.Duration(0))

However, it seems that it wont be so easy:

$ rosrun cvut_sandbox test_tf2_listener.py 
Traceback (most recent call last):
  File "/home/wagnelib/Source/hydro/clopema_ws/src/clopema_cvut/cvut_sandbox/scripts/test_tf2_listener.py", line 11, in <module>
    (trans, rot) = tfl.waitForTransform('r1_link_1', 'r2_link_2', rospy.Time(0), rospy.Duration(0))
AttributeError: TransformListener instance has no attribute 'waitForTransform'

Following the Writing a tf2 listener (Python) tutorial I ended with this:

#!/usr/bin/env python

import roslib; roslib.load_manifest('cvut_sandbox')
import rospy
import tf2

if __name__ == '__main__':
    rospy.init_node("test_tf_listener")
    tfl = tf2.TransformListener()
    (trans, rot) = tfl.waitForTransform('r1_link_1', 'r2_link_2', rospy.Time(0), rospy.Duration(0))

But it also fails:

$ rosrun cvut_sandbox test_tf2_listener_2.py 
Traceback (most recent call last):
  File "/home/wagnelib/Source/hydro/clopema_ws/src/clopema_cvut/cvut_sandbox/scripts/test_tf2_listener.py", line 5, in <module>
    import tf2
ImportError: No module named tf2

So is there a working example?


Originally posted by liborw on ROS Answers with karma: 801 on 2013-09-03

Post score: 5

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

See https://github.com/ros/geometry/issues/30 for the continuing discussion.


Originally posted by tfoote with karma: 58457 on 2015-11-06

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by 130s on 2018-09-19:
And that ticket seems to be resolved. Marked as an answer.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.