Is it safe and efficient for several threads to share a single tf::TransformListener object?
I am developing a multi-threaded ROS (kinetic/melodic) node that will rely on tf::TransformListener
to wait until it is possible to perform transformations (using waitForTransform(...)
), and then perform the transformations (using lookupTransform(...)
), if the transform exists.
My question is whether or not it is safe and efficient for all threads to share a single tf::TransformListener
object:
- Is it safe for several threads to call methods on a single
tf::TransformListener
object simultaneously? - If a thread calls one of the above-mentioned methods, will any other thread be able to call the same (or another) method on the same
tf::TransformListener
object and run in parallel with the first thread, or will the second thread be blocked until the first thread has finished its call? Having the threads running in parallel, without blocking, is of high importance. - In case threads would block (then to avoid threads from blocking), would it be okay to have several
tf::TransformListener
objects running inside a single node (one listener for each thread inside the node)? My intuition says that the same transformation trees would be built and maintained for each thread, which I think seems very bad from an efficiency point of view.
I apologize for any duplicate posting (I was unable to find the answer in the forum) but would be grateful for any answer you could provide!
The design docs at least mention the words "thread safe" (here).