autonomous_systems
autonomous_systems copied to clipboard
tf problem
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
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]