You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Pass a boolean flag, unsubscribe_on_terminate, to all subscription behaviors. Have it default to False (current behavior).
In setup(), we store self.node. Further, if unsubscribe_on_terminate is False, we create the subscription.
In initialise(), if unsubscribe_on_terminate is True, we create the subscription.
In terminate(), if unsubscribe_on_terminate is True, we destroy the subscription.
In shutdown(), if unsubscribe_on_terminate is False, we destroy the subscription.
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.
The text was updated successfully, but these errors were encountered:
Currently, once you run
setup
on any behavior inpy_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:
unsubscribe_on_terminate
, to all subscription behaviors. Have it default toFalse
(current behavior).setup()
, we storeself.node
. Further, ifunsubscribe_on_terminate
isFalse
, we create the subscription.initialise()
, ifunsubscribe_on_terminate
isTrue
, we create the subscription.terminate()
, ifunsubscribe_on_terminate
isTrue
, we destroy the subscription.shutdown()
, ifunsubscribe_on_terminate
isFalse
, we destroy the subscription.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.
The text was updated successfully, but these errors were encountered: