feat: implement lifecycle-aware service wrappers#5893
Conversation
|
Please fill in the PR template properly |
|
I noticed that the individual tests pass when I run with FASTDDS_BUILTIN_TRANSPORTS=UDPv4, but test_route keeps timing out during the compute_and_track_route action execution. Earlier I figured out that services need to be explicitly activated in on_activate() for lifecycle nodes, otherwise we hit the “service called while not activated” warnings. Adding that fixed those warnings. |
SteveMacenski
left a comment
There was a problem hiding this comment.
Do also make sure to remove commented out code; if this is still WIP, please mark as a draft :-)
I imagine there's other services that should also be migrated before a complete to-be-merged PR is submitted
| void ReroutingService::on_activate() | ||
| { | ||
| if(service_) { | ||
| service_->on_activate(); |
There was a problem hiding this comment.
If later handling managed nodes through registering them, will these be registered against the node to transition up/down?
There was a problem hiding this comment.
@Prathmesh2931 Can you answer? I'm curious if when we auto transition if we need to even keep all the activate()/deactivate() functions here or if even as sub-modules of the node will auto transition as well.
There was a problem hiding this comment.
I agree that auto-transition would simplify things and could potentially remove the need for explicit activate() / deactivate() calls.
However at the moment the plugins are not registered for automatic lifecycle propagation from the parent node. Because of that the lifecycle state is not automatically forwarded to sub-modules.
To stay consistent with the existing Nav2 plugin pattern, explicit activation/deactivation calls are currently still required.
If we later refactor to support proper lifecycle propagation, we could revisit and simplify this.
There was a problem hiding this comment.
However at the moment the plugins are not registered for automatic lifecycle propagation from the parent node. Because of that the lifecycle state is not automatically forwarded to sub-modules.
Isn't add_managed_entity in the lifecycle node factory adding all services, even in sub-modules to the list? They're all operating on the same node object. Why wouldn't this work?
There was a problem hiding this comment.
You are right add_managed_entity could theoretically handle this, if the services were registered globally with the node factory. Since these services are currently managed as private members within the specific server (like PlannerServer or RouteServer) they are not automatically included in that managed list. I have kept the explicitactivate()/deactivate()calls to stay consistent with how Nav2 currently manages internal plugin components, but I agree that a future refactor to use a centralized managed entity list would be a great simplification.
This is correct, we need to now activate them
I don't 100% understand. We are creating the services as usual on usually TF has its own thing going on that we're not messing with. Action srever should also be made lifecycle aware so that they cannot be called until activated. I think something missing from this PR is the failure back to the caller. If not active, the service request should return failure. though, the mechanism which that happens would basically need to have some "success" field in the service definitions to set the failure (I think). Actions on the other hand have a nice goal rejection mechanism that we can use for this generically (i.e. in the goal acceptance stage, if not active, reject).
For example? |
4404600 to
0b25246
Compare
|
@SteveMacenski, can you let me know if I'm on the right track with this gated |
|
@mini-1235, it would be great if you could take a look at this once. |
|
@SteveMacenski , just want to follow up when you have a moment . I have verified implementation of gated |
|
My apologies, I'm needed to triage my mental load and I want to get that first PR with the subscribers done before messing with the services. I didn't expect you to get this done so fast so sorry for the delay :( Please review the other comments that are still open from my first review, there are still quite a few of the files that changed that shouldn't be (such as the yamls for the route graph) and commented out lines that need to be removed |
I am working on it currently |
48f307f to
108c0a7
Compare
|
Most probably, CI is running out of resources. I checked on my local system, did a full build, and ran all package test cases, which showed 100% passing. So what should I do? |
|
I believe the build and tests are now successful. Please let me know if I should proceed with these changes. |
SteveMacenski
left a comment
There was a problem hiding this comment.
Thank you, this looks much better now!
63d7e02 to
f7186c9
Compare
SteveMacenski
left a comment
There was a problem hiding this comment.
Close! Please review any remaining open comments, there are several unaddressed
f7186c9 to
9202f17
Compare
SteveMacenski
left a comment
There was a problem hiding this comment.
Smaller clean up now but largely approved!
@mini-1235 please review to sanity check me and make sure they didn't miss any other services they should have converted
I am honestly not very familiar with the objective of the issue at the moment. I will read through it and review this PR by the end of the week |
0aec4eb to
b7e6686
Compare
|
@SteveMacenski, thank you for the feedback and approval of the pattern.I'd like to clarify some points: On Test Validity & Default ResponsesThe tests pass because they explicitly verify that requests are rejected when the service is inactive. The callback counter ( Example from test: This confirms service do not execute while inactive. On
|
|
Looking at the latest commit, I noticed that some services, such as I am having trouble understanding the discrepancy between these two cases. Could you please clarify what the difference is between them, @Prathmesh2931? |
|
Also please pull in / rebase main to fix the test errors |
1 . New auto managed :For standard services like 2 . Plugins & Sub-modules:For services like |
|
We want to manually transition right now, because we need to setup an ordered policy about which interfaces are activated in which order to prevent segfaults/inactive states, especially for services and subscriptions which could use publisher or clients in their callback.
After we implement the sub/service/client then we can create our own eq. to that function where we transition up managed entities in an ordered way (publishers, clients, subscriptions, servers) so that senders are created before receivers so that any receiver callback that sends is able to be run. Right now the order in rclcpp_lifecycle (which we do not call) is based on the order its registered. |
changes - added more test case for service wrapper(test_service_server)
- on_activate/on_deactivate signal for Routetracker and Operation
Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
- removed unnecessary if condition
- Fixes timeouts in test_bt_navigator and test_pause_resume_controller by sync state
feat - Uses SFINAE to return success=false and error messages for inactive nodes
Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
…ted by helper fun Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
- set service from lifecycle_manager to active state to fix gated service blocking
- added safety condition for edge_scorer_ to avoid null pointer dereference
- lifecycle issue in collision_monitor_node pkg
add - broadcast tf from map to base costmap_cost_service
- added static tf broadcast to satisfy frame lookups in costmap tests
- added TearDown logic in test fixtures before creating new objects to prevent crashes
Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
…d lifecycle node.
- remove unnecessary comment block.
Add - docstrings + move up under configure in the file
rename to activate/deactivate in the config fuction
Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
…eT's logger
reverted- activate/deactivate function from service server
- remove excess comment
Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
-removed excess comments Add -added deoxygen and lines in req files Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
-handler to auto activate service in service server
fix -moved service activation at end of callback
-removed unnecessary if condition
Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
…shared
to keep wrapper lifecycle aware and get_node_base_interface to register lifecycle node
Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
- updated service server to WARN and log message Add - updated state check in shutdown() helper in unit test Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
Added Bridge to register managed entity with lifecycle_node. fix - Change handle service logger from Debug to Error. Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
- test fix for test_dock_database
- change method name from 'activate'->'on_activate' majorly over nav2_route pkg
- implement manual ordered service activation policy
Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
b7e6686 to
7232128
Compare
|
The factory now only handles the non-lifecycle case ( |
|
@mini-1235 , can you look forward if there are any service remaining to include around nav2 server that , I might have missed . |
|
Can you respond to my items in #5893 (comment)? I'm concerned that this appears (?) to be working when nothing should be or is actually activated previously. |
You are absolutely right . After reviewing Test appear to pass:The auto-activation fallback in constructor activates the service while node is already I was thinking to solve these without relying on
This maintain order policy while keeping activation explicit and visible . |
mini-1235
left a comment
There was a problem hiding this comment.
Can you also double check that you have tested these changes in simulation? For example, try a few services from AMCL/costmap/route server to confirm they are all still functioning correctly
| db.initialize(node, nullptr); | ||
| db.activate(); | ||
| db.deactivate(); | ||
| bool initialized = db.initialize(node, nullptr); |
There was a problem hiding this comment.
Can you explain the changes here
| goal_handle: ServerGoalHandle[NavigateToPose.Goal, | ||
| NavigateToPose.Result, NavigateToPose.Feedback, | ||
| NavigateToPose] | ||
| goal_handle: ServerGoalHandle |
There was a problem hiding this comment.
Revert? I don't see how it is related?
Is that really true? If we're in the
I'd like to keep
This is very similar to my high level intent. I was actually going to leave the Then in So, we're thinking essentially the same thing it appears! I'm just thinking of this down the line once these 2x PRs are complete and we have the eq. for Service & Action Clients. I'm only looking to do that once we have all of them we can do in bulk so we don't end up in weird transient states in the |
Basic Info
Description of contribution in a few bullet points
ServiceServerwrapper being activated during lifecycle node transitionservice->on_activate()calls inplanner_server,route_server, and other lifecycle nodes that create servicesDescription of documentation updates required from your changes
No documentation updates required.
Description of how this change was tested
colcon test --packages-select nav2_ros_common nav2_planner nav2_route --event-handlers console_cohesion+nav2_system_testwithFASTDDS_BUILTIN_TRANSPORTS=UDPv4colcon test --packages-select nav2_system_tests --ctest-args -R test_planner_is_path_valid --event-handlers console_direct+which previous cause timeout issue or logic failFuture work that may be required in bullet points
LifecycleNodeclass to automatically manage service lifecycle registrationtest_routetimeout issue which unrelated to service activation , requires changes in action serverFor Maintainers:
backport-*.