TF waitForTransform buggy behaviour?
I am having an issue similar to what's being described here.
I call waitForTransform (with 5 sec delay) and then call transformPoint using the respective frames. It waits 5 seconds and then gives an error. Here is the code:
try:
print 'waiting for transform from %s to %s' % (target_frame, ps.header.frame_id)
listener.waitForTransform(ps.header.frame_id, target_frame, rospy.Time(0), rospy.Duration(5.0))
res = listener.transformPoint(target_frame, ps).point
except tf.LookupException:
print 'Failed to retreive transformation, took too long (I guess)'
except (tf.ConnectivityException, tf.ExtrapolationException):
print 'Other errors...\n'
And the error:
waiting for transform from map to
camera_depth_optical_frame
[ERROR] [1511494445.671395]: bad callback: <function boundingBoxCallback at 0x7f9415860f50>
Traceback [...]
**Exception: . canTransform returned after 5.00655 timeout was 5.**
This last line gives me the feeling that waitForTransform is simply pausing the program for 5 seconds and not listening to see if the transformation becomes available during the time. Regardless, rosrun tf tf_echo /map /camera_depth_optical_frame gives the transformation in less than 5 seconds.
Could this be a bug?
For me to help you more can you provide a self contained example that exhibits the behavior. It's not clear what your setup is or where the exception is coming from.
Oh, it's worked now, but still very weird. In waitForTransform(), 3rd param, if I change
rospy.Time(0)
torospy.Time.now()
, it throws an exception: "TypeError: unsupported operand type(s) for +: 'Time' and 'Time'."However, it works if I do:
now = rospy.Time.now()
and then call waitForTransform() usingnow
in the 3d argument. This is so weird and feels unstable :/Without a reproducible example it's going to be hard to debug your problem. You're trying to add two times which is not valid. Are you passing a time where there should be a duration?
Thank you for your time. My point is that if I call
listener.waitForTransform(frame1, frame2, rospy.Time.now(), rospy.Duration(5.0))
it gives the TypeError I described. However, doingnow = rospy.Time.now(); listener.waitForTransform(frame1, frame2, now, rospy.Duration(5.0))
it works.I don't think it should give error, it's supposedly the same thing. Also, the original problem (described in the question) I guess what's wrong is using
rospy.Time(0)
instead ofrospy.Time.now()
.