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

yet another tf extrapolation question

asked 2014-09-03 06:15:04 -0600

McMurdo gravatar image

This is the piece of code that I have used.

I am trying to transform a geometry_msgs::PointStamped from "base_link" to "map".

geometry_msgs::PointStamped _s , our_s;
_s.point.x = 0.929;
_s.point.y = 0.103672;
_s.point.z = 1.05381;

_s.header.frame_id = "base_link";
_s.header.stamp = ros::Time::now();


tf_l.waitForTransform("map", "base_link", _s.header.stamp, ros::Duration(1.0));
try
{
    tf_l.transformPoint("map", _s, our_s);

}
catch(tf::TransformException& ex)
{
    ROS_INFO("%s is the exception.", ex.what());
}

This is the same piece of code I always use. I normally get the output right, but now I get: the error

[ INFO] [1409742709.610312612]: Lookup would require extrapolation into the past.  Requested time 1409742709.104081534 but the earliest data is at time 1409742709.353810000, when looking up transform from frame [base_link] to frame [map] is the exception.

In this case: rosrun tf_echo view_frames shows the frames and they are great.

And rosrun tf tf_echo map base_link gives:

At time 1409742686.330
- Translation: [4.626, -0.504, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.205, 0.979]
            in RPY [0.000, 0.000, -0.413]
At time 1409742687.237
- Translation: [4.626, -0.504, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.205, 0.979]
            in RPY [0.000, 0.000, -0.413]
At time 1409742688.337
- Translation: [4.626, -0.504, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.205, 0.979]
            in RPY [0.000, 0.000, -0.413]
At time 1409742689.247
- Translation: [4.626, -0.504, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.205, 0.979]
            in RPY [0.000, 0.000, -0.413]
^CAt time 1409742689.664
- Translation: [4.626, -0.504, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.205, 0.979]
            in RPY [0.000, 0.000, -0.413]

I have gone through a lot of questions. I still understand this problem correctly. Any help is greatly appreciated.

Thank you so much.

edit retag flag offensive close merge delete

Comments

What is the frequency of tf between [base_link] to [map] , may be its less than your waiting time 1 second.

bvbdort gravatar image bvbdort  ( 2014-09-03 06:40:46 -0600 )edit

I get the same result if the duration is increased to 3 seconds

McMurdo gravatar image McMurdo  ( 2014-09-03 06:58:20 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-09-03 07:38:31 -0600

Tom Moore gravatar image

updated 2014-09-03 07:44:38 -0600

waitForTransform has a boolean return type that indicates success or failure. If it returns false, you reached your timeout period, and something is likely not right about your transforms. Do something like this:

if(tf_l.waitForTransform("map", "base_link", _s.header.stamp, ros::Duration(1.0)))
{
  try
  {
      tf_l.transformPoint("map", _s, our_s);
  }
  catch(tf::TransformException& ex)
  {
      ROS_INFO("%s is the exception.", ex.what());
  }
}
else
{
  ROS_INFO("No transform available!");
}

The way you have it written, it's going to attempt the transform whether waitForTransform succeeds or not.

EDIT: Also, what is producing the map to base_link transform? Is it on the same machine? What time stamp value is being used for the transform when it gets broadcast?

edit flag offensive delete link more

Comments

Part 1 of your answer is probably the right answer. Thanks!

The odometry/laser and navigation modules are connected to ROS from a proprietary software. This bridge is what publishes the transform from map to base_link. I am sure it is published properly... But something is happening here.

McMurdo gravatar image McMurdo  ( 2014-09-11 01:46:15 -0600 )edit

contd. probably a bug in the implementation of this bridge itself. I solved the issue by doing this: 1. Get the transform as a tf::StampedTransform using lookupTransform() 2. Use tf::Vector3 and do simple multiplication.

McMurdo gravatar image McMurdo  ( 2014-09-11 01:47:27 -0600 )edit

my program crashes at waitForTransform already saying tf tries to extrapolate into the Future/Past! this doesn't make any sense...

Mehdi. gravatar image Mehdi.  ( 2015-04-21 07:34:05 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-09-03 06:15:04 -0600

Seen: 345 times

Last updated: Sep 03 '14