-
Notifications
You must be signed in to change notification settings - Fork 449
Registration of multiple callbacks on state transition #2216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This use case can easily be implemented on the application side (e.g. your mother node has a list of callbacks and it register a callback that iterates through them). This also seems a better approach to me, since it allows you to hide the lifecycle details from the child nodes. |
@alsora Thank you for the suggestion. I might do something like that for the time being. Nevertheless, I still think this feature would be useful. What if I do not want to hide the lifecycle details from the child nodes? What if I want the child node to be able to register callbacks for all the possible transitions? Moreover, the semantic of the name |
@LastStarDust I think this is a good idea in theory but agree with @alsora that this should probably live as application-side behavior.
I would argue:
I.e.
This is a good point, possibly future consideration of renaming to |
@tgroechel Point taken. I am going to implement this at the application level. As you say, it takes a little effort but it has its merits to manage this at the application level. |
Feel free to close this issue. |
@alsora @LastStarDust @tgroechel
i am not sure how this is related to multiple callbacks support? this sounds to me one of the application designs. i think that as if a
this still can be supported with multiple callbacks? if no callbacks are registered in the map, we can return
true. besides, my major concern was what do you think? |
@fujitatomoya Thanks for the follow up, my thoughts below. Apologies for large comment, I wish Github had threads.
Ah wrote my response a bit quickly. I was meaning this to be an example of how a user could design their application. I still think single callback in the lifecycle backend is "better" design (see below).
I don't know the history but I would hedge this - the lifecycle backend not knowing how to handle rollbacks - is the core reason (and better than my given reasons #2216 (comment)). I think a core idea is that the user is the only one who knows how to "rollback" a transition (unloading, flipping flags etc.) with it being the user's responsibility to return a
Therefor it is the user's responsibility to rollback anything that they may have done during a transition. I have an open Issue / PR for these responsibilities outlined here: #2212
I think this is likely a common design pattern (loading multiple dependencies, often external such as parameters & hardware), especially in
I think a good way to address this is via adding response deferral functionality to lifecycle transitions: #2213
|
This issue has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/deferrable-canceleable-lifecycle-transitions/32318/1 |
Feature request
Feature description
It would be nice if it was possible to register multiple callbacks to be called on a certain state transition.
The callbacks should be called in the order of insertions.
For example, in the current implementation every time the method
register_on_activate(callback)
is called, the previous callback is overwritten.Implementation considerations
This is because the callback container is implemented as a map.
See lifecycle_node_interface_impl.hpp#L149-L151:
Why do we need it?
I feel this question might be coming.
For example, imagine a MotherNode class that is extended by a ChildNode class. The MotherNode might want to register a basic callback, but the ChildNode might want to register another callback to be called after that. In the current implementation, the ChildNode callback would overwrite the MotherNode callback.
BTW this happened to me personally today, and it took me a while to understand the cause of the issue.
The text was updated successfully, but these errors were encountered: