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

Revision history [back]

click to hide/show revision 1
initial version

As @gvdhoorn mentions your timestamp usage is inconsistent and you should be using the timestamp of the data neither now() nor TIme(0)

tf internally keeps a buffer of the past transform data to allow you to query it at a specific time. When the laser scan is collected you should collect as exact a timestamp as possible at the time of capture. In parallel you should be publishing the joint states as accurately as possible.

Then when you want to transform your laser scan into a point at the time it was collected. Not the current transform etc. So you should be transforming at the time of the data.

Now it may be that the transform data is slower to propogate depending on your network topology. So you could use waitForTransform but a much better solution is to use a MessageFilter which will efficiently hold the data for you until the transforms are available.

There are tutorials here: http://wiki.ros.org/tf2/Tutorials/tf2%20and%20time%20%28C%2B%2B%29 and here: http://wiki.ros.org/tf2/Tutorials/Using%20stamped%20datatypes%20with%20tf2%3A%3AMessageFilter

On each of those topics. I'd also strongly recommend switching to tf2 from tf as tf has been deprecated and is just a backwards compatibility layer for tf2.