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

Revision history [back]

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:

  • The queue gets filled with laser scan messages from the "past" (i.e., the first second or so before the node was started).
  • Your callback works through the queue one message at a time; since waitForTransform() times out, this takes 1 second per message.
  • If you don't get a valid transform for the first 15 messages, all remaining messages will now fail because the TF buffer is only 15 seconds (or so) long.

This might also explain why adding 1 second "solves" the problem.