splintered-reality / py_trees_ros

ROS extensions and implementations for py_trees
Other
143 stars 40 forks source link

Option to Destroy Subscription in `terminate` #218

Open amalnanavati opened 9 months ago

amalnanavati commented 9 months ago

Currently, once you run setup on any behavior in py_trees_ros/subscribers.py, that subscription is active and accepting messages until the code terminates and it is garbage-cleaned. This means it stays on the wait set and consumes resources from the callback group, even at times we don't need it. For example, if we have a large tree and only want to subscribe to a topic in one particular behavior, we can destroy the subscription afterwards to save resources.

I'd propose the following implementation:

Let me know what you think. We have certain subscribers that we only need at particular parts of the tree (e.g., only subscribe to object detection after the robot has moved to a pre-grasp pose) and we don't want it consuming callback resources during the rest of the tree.