# tf: Lookup would require extrapolation into the past

I've written the following method for returning the homogeneous transformation matrix between two tf links:

```
Eigen::Matrix4f getTransformation(std::string parentName, std::string childName){
parentName.insert(0,"/");
childName.insert(0,"/");
tf::StampedTransform transform;
tf::TransformListener listener;
ros::Time t = ros::Time::now();
try{
listener.waitForTransform(parentName, childName, t, ros::Duration(4.0));
listener.lookupTransform(parentName, childName, t, transform);
}
catch (tf::TransformException ex){
ROS_ERROR("%s",ex.what());
}
tf::Matrix3x3 rot = transform.getBasis();
tf::Vector3 trans = transform.getOrigin();
Eigen::Matrix4f tranformation = Eigen::MatrixXf::Identity(4,4);
Eigen::Matrix3f upleft3x3;
upleft3x3 << rot[0][0], rot[0][1], rot[0][2],
rot[1][0], rot[1][1], rot[1][2],
rot[2][0], rot[2][1], rot[2][2];
tranformation.block<3,3>(0,0) = upleft3x3;
tranformation.col(3) = Eigen::Vector4f(trans[0],trans[1],trans[2],1);
return transformation;
}
```

When I try to use this method, I get the following error:

```
Lookup would require extrapolation into the past. Requested time 1406560524.442721448 but the earliest data is at time 1406560524.444821575, when looking up transform from frame [wrist_3] to frame [base_link]
```

I tried the solution suggested by Martin Günther on this page, but that just resulted in an infinite while loop.

Adding a `ros::Duration(1)`

to the requested time worked, but obviously that isn't ideal. Any other solutions?

When does this happen? Once at the start or all the time?

I get the error whenever the function is called.