autonomous_systems icon indicating copy to clipboard operation
autonomous_systems copied to clipboard

tf problem

Open oscar-lima opened this issue 7 years ago • 1 comments

Question: We have some problems with the lookupTransform. We are asking the more recent position of the robot and upon a time it returns us an older position instead of the current one.

We have already used rospy.Time(0) and this doesn't solved our problem

oscar-lima avatar Nov 20 '17 12:11 oscar-lima

Thats weird, rospy.Time(0) should give you the latest tranform.

My advice is for you to check the code against this snippet:

import tf
import rospy

listener = tf.TransformListener()
wait_for_transform = 0.1
reference_frame = "my_reference_frame"
target_frame = "my_target_frame"

try:
    listener.waitForTransform(reference_frame, target_frame, rospy.Time(0), rospy.Duration(wait_for_transform))
    (translation, rotation) = self.listener.lookupTransform(reference_frame, target_frame, rospy.Time(0))
except tf.Exception, error:
    rospy.logwarn("Exception occurred: {0}".format(error))

# x, y, z

translation[0]
translation[1]
translation[2]
# quaternion

print rotation[0]
print rotation[1]
print rotation[2]
print rotation[3] 

oscar-lima avatar Nov 20 '17 12:11 oscar-lima