TF waitForTransform buggy behaviour?

asked 2017-11-23 21:49:22 -0500

db gravatar image

updated 2017-11-24 12:17:41 -0500

jayess gravatar image

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?

edit retag flag offensive close merge delete

Comments

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.

tfoote gravatar image tfoote  ( 2017-11-26 16:59:04 -0500 )edit

Oh, it's worked now, but still very weird. In waitForTransform(), 3rd param, if I change rospy.Time(0) to rospy.Time.now(), it throws an exception: "TypeError: unsupported operand type(s) for +: 'Time' and 'Time'."

db gravatar image db  ( 2017-11-30 16:01:31 -0500 )edit

However, it works if I do: now = rospy.Time.now() and then call waitForTransform() using now in the 3d argument. This is so weird and feels unstable :/

db gravatar image db  ( 2017-11-30 16:04:09 -0500 )edit

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?

tfoote gravatar image tfoote  ( 2017-11-30 16:05:23 -0500 )edit

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, doing now = rospy.Time.now(); listener.waitForTransform(frame1, frame2, now, rospy.Duration(5.0)) it works.

db gravatar image db  ( 2017-11-30 16:16:31 -0500 )edit

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 of rospy.Time.now().

db gravatar image db  ( 2017-11-30 16:19:00 -0500 )edit