-
Notifications
You must be signed in to change notification settings - Fork 237
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
Implement managed nodes #865
Conversation
rclpy/rclpy/lifecycle.py
Outdated
return TransitionCallbackReturn.SUCCESS | ||
|
||
|
||
class SimpleManagedEntity(ManagedEntity): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there motivation to have the SimpleManagedEntity
inherit from a ManagedEntity
other than that they share two intended transitions (activate/deactivate). Presumably the other transitions do not do anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought in some cases it could be useful to override some of the others, so I left all of them.
e.g. you can inherit from LifecyclePublisher and override on_error()
.
I'm not sure if that's really useful or not.
If the only use-case we see is something like SimpleManagedEntity
, i.e. setting/clearing a flag in on_active/on_deactive, maybe it would be simpler to just keep a reference of the lifecycle node state machine in all managed entities and query if the current state is active or not.
That might be a bit slower, as there a few extra indirections and comparisons.
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
…ally manage child entities Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
…improvements Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
…ce=False Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
54b6dab
to
ce0d256
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good to me. It will be very nice to have lifecycle nodes in rclpy! I've commented on a few TODOs and made a few minor suggestions.
It would also be good to have a tutorial written for this at the same time that we merge in this PR.
Also, do you still intend to add more tests, or does that about cover it?
node = LifecycleNode( | ||
'test_lifecycle_state_transitions_1', enable_communication_interface=False) | ||
# normal transitions | ||
assert node.trigger_configure() == TransitionCallbackReturn.SUCCESS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe have a for loop put the node through many transitions, just to confirm that they work back-to-back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC after 4ca2a36 I'm testing all the possible transitions back to back.
I find it clear to do them manually instead of in a for loop, but if you have a code snippet that you find better feel free to share it.
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]> Co-authored-by: Audrow Nash <[email protected]>
…r reuse in LifecycleNode and other derived classes Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
…ged entitities. Share implementation of default transtion callbacks Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
…hen shutdown transition is not possible Signed-off-by: Ivan Santiago Paunovic <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me with green CI.
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
I will request more feedback about the API, particularly considering it doesn't match exactly the rclcpp one (following the suggestion in ros2/rclcpp#1846). |
Going in, thanks for the review @audrow !! |
@ivanpauno any plans for adding docs that this exists? This came up here: ros-navigation/navigation2#3259 and while trying to show them documentation for the API, I came up with lint in my pockets 😄 |
Yes sorry, there's not much more than the demo added in this PR up to now. |
This pull request has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/lifecycle-nodes-in-python/14547/4 |
Fixes #604.
I took into account the feedback provided here ros2/rclcpp#1846, so you don't need to manually call on_activate/on_deactivate for managed entities like
LifecyclePublisher
.I'm open to revert that bit, though I think it's a good idea.
I have only manually tested that the lifecycle node services work correctly.I have not tested the lifecycle publisher at all.
This PR has tests now.
I could write some automated tests for the lifecycle builtin services though.Done as well.
This is not ready to be merged, though early feedback is appreciated anyway.This is ready now.
I'm working to add a demo equivalent to demos/lifecycle, but that shouldn't block this from being reviewed.PR with demo ready: ros2/demos#547.