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

You say it's taking "quite a long time" but you don't provide any numbers. So it's hard to help you too much. The query times for the lookupitself are on the order of microseconds. I ran the performance tests recently for this question https://answers.ros.org/question/377241/can-a-ros-2-tf-buffer-be-queried-in-time-critical-code/?answer=377593#post-id-377593 Querying for each transform is relatively low overhead. There's potentially a slight optimization if you were to build up every single transform in the tree while walking it. However it would only be a marginal benefit worth doing for a very large tree. But I don't think that's where you should worry about optimizing.

You're right that using waitForTransform within a loop is something that I would recommend against. You should be able to waitForTransform for the most recent one and then just query for the previous values assuming data is being generated in order.

Also, I don't know what your resolution of querying is. But if you're querying for a transform within a very small window (aka at very high resolution tf is doing interpolation for any of those intermediate points. You could likely do the same at a higher level and reduce the number of queries.