ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Wait for TF listern queue to not be empty

asked 2012-02-15 07:41:06 -0500

pbeeson gravatar image

updated 2014-01-28 17:11:23 -0500

ngrennan gravatar image

I am noticing an issue with TF LIsteren in Electric that doesn't seem to be covered by other questions. Mainly, if I create a TF listener tf_, then immediately go into a callback that calls tf_.waitForTransform(...), I get: "terminate called after throwing an instance of 'tf::ExtrapolationException' what(): Unable to lookup transform, cache is empty, when looking up transform from frame ...."

What it seems is that the listener hasn't been active long enough to get any TF information before waitForTransform is called, and when you call waitForTransform on a listener with an empty cache/queue, is throws this exception deep down (I can't catch it at the level of calling waitForTransform) and the process is ended.

I'd like to be able to first look to see if the cache is not empty, or be able to catch this at the high level.

Any suggestions?

BTW, the only way I've found around this so far is to sleep for a couple of seconds after creating the listener and before calling waitForTransform().

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-02-15 11:39:48 -0500

pbeeson gravatar image

updated 2012-02-17 04:57:55 -0500

The problem was that when running Gazebo (and it being VERY slow due to having walls -- I have a separate bug Trac on that that hasn't been answered), TF comes in much slower than the program executes, so waitForTransform bombs out (cannot catch exception because something catches it first and quits).

I can get around this by using canTransform() and throwing out the scan is that fails, or catching the TransformException on the transformPoint() call directly. That is easiest.

edit flag offensive delete link more
0

answered 2012-02-15 10:30:12 -0500

This is a complete shot in the dark, but have you tried calling ros::spinOnce() before the waitForTransform call?

Or equivalently, creating the listener outside of the main ros loop, and calling the waitForTransform after ros::spin() has been entered?

edit flag offensive delete link more

Comments

Yes. I did try that. The problem here was that the simulation was running so slow, that TF entries are VERY slow to arrive in real world time. Being outside the main loop only works if you know what the frame id is ahead of time, and yes I tried it anyway and it didn't work.

pbeeson gravatar image pbeeson  ( 2012-02-16 01:22:39 -0500 )edit

Question Tools

Stats

Asked: 2012-02-15 07:41:06 -0500

Seen: 1,255 times

Last updated: Feb 17 '12