Ask Your Question
0

tf::TransformListener results in Lookup would require extrapolation into the future. Requested time 'x' but the latest data is at time 'y', when looking up transform from frame [odom] to frame [base_footprint]

asked 2021-07-03 01:36:14 -0500

Rika gravatar image

updated 2021-07-03 01:37:21 -0500

Hello everyone. I have been tyring to meddle with tf::TransformListiner and see how it works. but every time I try to run my example, I get :

Lookup would require extrapolation into the future.  Requested time 2873.875000000 but the latest data is at time 2873.867000000, when looking up transform from frame [odom] to frame [base_footprint]

I tried to set the "/amcl/transform_tolerance" to some other values (ranging from 1/10 seconds to 0.01) to no avail. This seems to have been caused by running both gazebo turtlebot3 simulation alongside rviz2 on my system (in a vmware workstation) and seems its struggling because my CPU cant handle such load and thus it introduced a small latency and messed up everything.

apart from using a more powerful PC which at the moment is not possible, what should I do ? I have read about FilterMessages`, but honestly don't know which one to use and how, since I'm not directly dealing with topics here.

note : I'm using C++ by the way in case it matters.

Any help is greatly appreciated and thank you all very much in advance.

edit retag flag offensive close merge delete

Comments

What do you mean by "rviz2"?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-07-03 07:57:07 -0500 )edit

That's a typo, my RViz version was 1.12.17

Rika gravatar image Rika  ( 2021-07-03 22:01:20 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2021-07-03 06:00:50 -0500

Rika gravatar image

updated 2021-07-05 23:37:45 -0500

Thanks to Photon, after consulting the official documentation (Learning about tf and time (C++)) I found where my problem was.

First of all I had a (wrong) preconception that Time(0) and Time::now() refer to the very same thing and are interchangeable. I couldn't have been more wrong about this. They are not the same.
The Time(0) means "the latest available transform in the buffer" while Time::now(), literally fetches the frame at the exact moment, and since there is a delay between this command being issued and the frame being fetched, we will have some latencies in milliseconds and this will cause the lookup failure if its not accounted for.
Why is that?(based on tf2 docs which I believe also applies to tf) :

Each listener has a buffer where it stores all the coordinate transforms coming from the different tf broadcasters. When a broadcaster sends out a transform, it takes some time before that transform gets into the buffer (usually a couple of milliseconds). So, when you request a frame transform at time "now", you should wait a few milliseconds for that information to arrive.

In order to fix this I either had to use Time(0) and get the latest available transform in the queue or if I wanted the frame at roughly now, I had to use waitForTransform()

So to cut a long story short, I either had to do :

 transform_listener.lookupTransform("base_footprint", "odom",ros::Time(0), transform);

or:

ros::Time now = ros::Time::now();
transform_listener.waitForTransform("base_footprint", 
                                    "odom", 
                                     now, 
                                     // the wait duration in seconds
                                     ros::Duration(2));
//note that we used 'now' here as well. if we don't, we will still face lookup error
//as if nothing has changed
transform_listener.lookupTransform("base_footprint", "odom", now, transform);
edit flag offensive delete link more
1

answered 2021-07-03 04:03:12 -0500

photon gravatar image

One way is to go through the tf tutorial separately without using Gazebo: http://wiki.ros.org/tf/Tutorials (It's pretty hard to get a decent performance of Gazebo running in a virtual machine, and the extrapolation issue is probably caused by this latency.)

edit flag offensive delete link more

Comments

Thanks, but I want to fix it rather than leaving it alone as I believe this can happen in real life as well. I want to know why setting transform_tolerence didn`t work, or what other options I have aside not using gazebo.

Rika gravatar image Rika  ( 2021-07-03 04:42:11 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-07-03 01:36:14 -0500

Seen: 97 times

Last updated: Jul 05