ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You should check for the return value of waitForTransform()
:
bool success = listener.waitForTransform("base_laser", "odom", time, ros::Duration(1));
if (success) {
listener.lookupTransform("base_laser", "odom", time, trans);
}
What happens is that waitForTransform()
fails, but you still call lookupTransform()
, so that's where the exceptions come from.
The next step is figuring out why your lookups time out. It's normal if that happens for the first few laser scans, since your TF listener wasn't yet buffering TF messages before your node got started. But after a very short while, these errors should disappear.
One thing to check is that you set the queue size of your laser scan subscriber to a small value (like 1). Otherwise, you'll have the following problem:
waitForTransform()
times out, this takes 1 second per message.This might also explain why adding 1 second "solves" the problem.