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

Why is a transform not available after waitForTransform?

asked 2014-10-08 04:09:49 -0500

Sebastian Kasperski gravatar image

Hello ros-users,

I have strange issue with tf-transforms. I use laser_geometry::LaserProjection to project laser scans to point clouds, but I assume the problem is related to tf. The code-snippet is from the scan callback function.

if(!gTfListener->waitForTransform(scan->header.frame_id,
                              "camera",
                              scan->header.stamp,
                              ros::Duration(2.0),
                              ros::Duration(0.01),
                              &error_msg))
{
    ROS_WARN("Warning 1: %s", error_msg.c_str());
    return;
}
try
{
    gProjector->transformLaserScanToPointCloud("camera", *scan, cloud, *gTfListener);
}catch(tf::TransformException e)
{
    ROS_WARN("Warning 2: %s", e.what());
    return;
}

After a few seconds of running, Warning 2 is raised on the console for like 1 out of 4 scans with this error message:

Warning 2: Lookup would require extrapolation into the future. Requested time 1412757571.359567610 but the latest data is at time 1412757571.357117891, when looking up transform from frame [laser_link] to frame [camera]

How can this happen, after waitForTransform obviously succeeded (returned true)?

Thanks in advance, Sebastian

edit retag flag offensive close merge delete

Comments

you could try to set a very long time for the duration (the time it should wait) . My computer was slow and it solved the problem

GuillaumeB gravatar image GuillaumeB  ( 2014-10-08 05:16:47 -0500 )edit

Increasing the wait time did not change the behaviour, as waitForTransform already returned true (e.g. didn't timeout)

Sebastian Kasperski gravatar image Sebastian Kasperski  ( 2014-10-08 07:43:15 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-10-08 07:40:20 -0500

Sebastian Kasperski gravatar image

updated 2014-10-08 07:41:38 -0500

My assumption about tf was wrong, the solution was indeed related to laser_geometry. As described here, the Projector uses start and end time of the scan and therefore asks for a timestamp in the future.

So to wait long enough, the call to waitForTransform should be:

if(!gTfListener->waitForTransform(
       scan->header.frame_id,
       "camera",
        scan->header.stamp + ros::Duration().fromSec(scan->ranges.size()*scan->time_increment),
        ros::Duration(2.0),
        ros::Duration(0.01),
        &error_msg))
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-10-08 04:09:49 -0500

Seen: 465 times

Last updated: Oct 08 '14