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

tf error: Lookup would require extrapolation into the past

asked 2015-03-20 18:54:52 -0600

scopus gravatar image

updated 2015-03-20 22:23:51 -0600

Hi, all. I want to convert a pose from "odom" to "map", I am using codes as follows.

  void PeopleAgent::TransformPos(const people_msgs::PoseArrayWeighted &msg) 
   {
        boost::mutex::scoped_lock lock(agent_mutex_);

        pose_array_weighted_.clear();
        geometry_msgs::PoseStamped in;
        in.header = msg.header;
        for (int i = 0; i< (int)msg.poses.size(); i++)
        {
            in.pose = msg.poses[i];
            geometry_msgs::PoseStamped result;
            try
            {
                tf_->waitForTransform("odom", "base_link", in.header.stamp, ros::Duration(0.2));
                tf_->transformPose("base_link", in, result);
                pose_array_weighted_.push_back(std::make_pair(msg.weights[i], result));
            }
            catch (tf::TransformException ex)
            {
                ROS_ERROR("%s",ex.what());
                ROS_ERROR("point transform failed");
            };
        } 
}

The above code works fine in my project, However, when the "base_link" is changed to be " map", then errors come up as follows:

 [ERROR] [1426895120.908823306, 1422676721.758969255]: Lookup would require extrapolation into the past.  Requested time 1422676720.347031633 but the earliest data is at time 1422676720.654202231, when looking up transform from frame [odom] to frame [map]
    [ERROR] [1426895120.908922891, 1422676721.758969255]: point transform failed

I also have tried to use

tf_->waitForTransform("odom", "map", ros::Time(0), ros::Duration(0.2));

or

tf_->waitForTransform("odom", "map", ros::Time::now(), ros::Duration(0.2));

but all failed.

Please tell me the reason why above errors come up and how to modify the code. Thank you

EDIT: Just now, I found that the above code with "base_link" worked fine only for rosbag files. When it was run in a real robot( turtlebot), same errors with "from frame [odom] to frame [base_link]" came up too.

I am very confused and don't know what I should do next.

edit retag flag offensive close merge delete

Comments

try increasing ros::Duration(0.2) upto maximum of 10 seconds.

bvbdort gravatar image bvbdort  ( 2015-03-21 02:01:15 -0600 )edit

I agree with your suggestion,maybe ros::Duration(1) is enough !

ShareIQ gravatar image ShareIQ  ( 2015-03-21 02:24:12 -0600 )edit

Thank you for your attention. I have modified the duration. It didn't help. Increasing the duration also lead to slowing the process because of boost::mutex::scoped_lock lock(agent_mutex_);

scopus gravatar image scopus  ( 2015-03-21 03:14:39 -0600 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2015-03-22 03:33:17 -0600

tfoote gravatar image

The error is telling you that your asking for a transform from a time before which you have tf data.

Most tf datasources report data in monotonic increasing order which means that no matter long you wait you will not receive older data.

You will either need to initialize the transform listener earlier and allow the buffer to fill up, or pass a few of these errors on startup. It's a common race condition whether the data or tf data arrives first.

edit flag offensive delete link more

Comments

Thank you ! As your suggestion, I have tried to wait for a while to see if the red errors (i. e. Lookup would require extrapolation into the past....)disapeared. But the running node collapsed. I still don't know why.

scopus gravatar image scopus  ( 2015-03-24 08:11:01 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2015-03-20 18:54:52 -0600

Seen: 9,326 times

Last updated: Mar 22 '15