Is there a reason that a lot of constructors in ROS based code take in tf2_ros::TransformListener
as one of the input? I want to get an idea from the design perspective.
1 Answer
The tf2_ros::TransformListener
takes up a relatively high amount of processing power because it subscribes to the publications of the high volume /tf
topics and caches the results locally in memory. It's much more efficient to have one copy which you access from multiple places in your code by passing a reference to it and querying it directly rather than instantiating multiple instances which will increasing network traffic, memory usage, and cpu usage for each instance.