rosbag play & tf extrapolation problems
Hi everyone,
I wrote a program for collecting laser data from a bag (currently I'm using a bag from the gmapping node tutorial).
The bag is executed as usually: rosbag play bag
No problems so far, I can visualize everything in rviz. Problems are on the listener side. The callback, rather basic, is the following:
void callBack(const sensor_msgs::LaserScan::ConstPtr& msg)
{
tf::TransformListener listener;
tf::StampedTransform trans;
try
{
ros::Time time=msg->header.stamp;
listener.waitForTransform("base_laser", "odom", time, ros::Duration(1));
listener.lookupTransform("base_laser", "odom", time, trans);
//Do something
}
catch(tf::TransformException ex)
{
ROS_ERROR("%s",ex.what());
}
}
In few words, it doesn't work, I always obtain:
Lookup would require extrapolation into the past
or
Lookup would require extrapolation into the future
I modified, by hand, the time variable value as follows:
ros::Time time=ros::Time(msg->header.stamp.sec+1);
Although it worked, to me is not a feasible or general solution.
Changing duration value didn't help either.
Am I doing something wrong? Maybe did I forget some parameter for ROS to set?
Thanks for your help,
Tambo