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

Another question about extrapolation in the past

asked 2018-02-26 07:10:23 -0600

Maya gravatar image

updated 2018-02-26 07:23:50 -0600

Hello all,

That's a question that has been asked multiple times but none of the solution have worked so far. I'm playing data from a rosbag and when trying to query the tf I have this error:

[ERROR] [1519650555.804462800, 1504014242.149115352]: Lookup would require extrapolation into the past.  Requested time 1504014237.046037623 but the earliest data is at time 1504014237.201914971, when looking up transform from frame [base_link] to frame [world]

Here is the code I'm using to query it :

ros::Time stamp = scan->header.stamp;
//Read transformation UGLY TRICK :P
tf::TransformListener listener(ros::Duration(50.0));
std::cout <<  listener.DEFAULT_CACHE_TIME << " " << listener.getCacheLength() << std::endl;
tf::StampedTransform transform;
try {
    listener.waitForTransform(odom_frame_, "/base_link", stamp, ros::Duration(5.0));
    listener.lookupTransform(odom_frame_, "/base_link", stamp, transform);
} catch (tf::TransformException ex) {
    ROS_ERROR("%s",ex.what());
}

As visible in the code, I tried to change the buffer size to some higher number but it seems this is ignored :/ ?

Also this function is in the callback to a messageFilter in gmappings code:

scan_filter_ = new tf::MessageFilter<sensor_msgs::LaserScan>(*scan_filter_sub_, tf_, odom_frame_, 1);
scan_filter_->registerCallback(boost::bind(&SlamGMapping::laserCallback, this, _1));

I'm running the rosbag with clock and I've set use_sim_time to true. I've also tried slowing down the rosbag to try have my algorithm catch up but I still have the same problem. So I'm at a loss on what the actual problem is. Using `ros::Time(0) instead of the haeder time stamp works.

What is wrong in the approach I'm having ?

edit retag flag offensive close merge delete

Comments

Do you get that error for every lookup or just the first few? Surely once the stamp gets past 1504014237.201914971 it starts working?

lucasw gravatar image lucasw  ( 2018-02-26 10:09:37 -0600 )edit

For all of them. That was the weird thing, it kept moving forward...

Maya gravatar image Maya  ( 2018-02-26 10:20:28 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-02-26 10:31:26 -0600

lucasw gravatar image

updated 2018-02-26 12:15:39 -0600

It looks like you are creating the tf listener in the callback that is receiving the scan, when it needs to be created as early as possible when your node starts and persist throughout (e.g. be a class member or a global).

I'm working on creating a set of boiler plate tf examples: https://github.com/lucasw/tf_demo

It will only be tf2, it's only python now but will get C++ next, and have examples with and without classes, and be linked to from the wiki pages. There are so many similar tf questions it'll be useful to point out at least my take on how it ought to be done, contributions are welcome also.

edit flag offensive delete link more

Comments

I'll try that ! That's most probably the problem

Maya gravatar image Maya  ( 2018-02-26 10:33:05 -0600 )edit
1

@lucasw Might I suggest extending/improving the tf2 tutorials here: https://github.com/ros/geometry_tutor... instead of a new resource?

tfoote gravatar image tfoote  ( 2018-02-26 12:46:51 -0600 )edit

Sure I'll take a look

lucasw gravatar image lucasw  ( 2018-02-26 13:39:14 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2018-02-26 07:10:23 -0600

Seen: 1,422 times

Last updated: Feb 26 '18