feat(opennav_docking): add on-demand detector client & unit tests for dock plugins (#5015)#5218
Conversation
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
f580de2 to
feb37e8
Compare
There was a problem hiding this comment.
Good first stab! I have some questions and suggestions, but largely its a good starting point for a couple of hopefully quick iterations. The changes requested in this plugin are the same in both, but I only reviewed the one just to avoid duplicating every comment. Take each comment for both plugin files
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
95ed998 to
dcb62d4
Compare
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
|
@bkoensgen re-request a review from me in the github UX when you're ready for me to take a look again (and CI is building 😉 ) |
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
3 similar comments
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
b6ee1e3 to
e000987
Compare
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
1 similar comment
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
118fe82 to
804520a
Compare
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
694feb0 to
7153b31
Compare
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
49cd52b to
76b096b
Compare
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
8b7d652 to
b3f4910
Compare
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
1 similar comment
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
cbf5362 to
e21641e
Compare
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
43d42bc to
4e7de42
Compare
|
@bkoensgen, your PR has failed to build. Please check CI outputs and resolve issues. |
…d explicit detection state flags Signed-off-by: bkoensgen <[email protected]>
…ed_ vs initial_pose_received_) and warn before first pose Signed-off-by: bkoensgen <[email protected]>
…arted_ vs initial_pose_received_) and warn before first pose Signed-off-by: bkoensgen <[email protected]>
Signed-off-by: bkoensgen <[email protected]>
…state Signed-off-by: bkoensgen <[email protected]>
… behavior (default=false) Signed-off-by: bkoensgen <[email protected]>
…stay in-scope) Signed-off-by: bkoensgen <[email protected]>
Signed-off-by: bkoensgen <[email protected]>
…Process() in terminal cleanup Signed-off-by: bkoensgen <[email protected]>
…ty->stopDetection->terminate) Signed-off-by: bkoensgen <[email protected]>
Signed-off-by: bkoensgen <[email protected]>
Signed-off-by: bkoensgen <[email protected]>
Signed-off-by: bkoensgen <[email protected]>
Signed-off-by: bkoensgen <[email protected]>
Signed-off-by: bkoensgen <[email protected]>
Signed-off-by: bkoensgen <[email protected]>
Signed-off-by: bkoensgen <[email protected]>
Signed-off-by: bkoensgen <[email protected]>
Signed-off-by: bkoensgen <[email protected]>
Signed-off-by: bkoensgen <[email protected]>
9062ad0 to
45f4bcb
Compare
|
So MergyBot should be happy now, and I’ve created the PR. Here’s the link: ros-navigation/docs.nav2.org#773 |
| rclcpp::Rate r(2); | ||
| r.sleep(); | ||
| executor.spin_some(); | ||
| rclcpp::spin_some(node->get_node_base_interface()); |
There was a problem hiding this comment.
Hi, rclcpp::spin_some is going to be deprecated in the next release of rclcpp, this should not be changed, see more information in #5521
| rclcpp::Rate r(2); | ||
| r.sleep(); | ||
| executor.spin_some(); | ||
| rclcpp::spin_some(node->get_node_base_interface()); |
|
This PR actually reverts some of the changes in #5521, I think we need to revert the changes related to |
… dock plugins (ros-navigation#5015) (ros-navigation#5218) * feat(opennav_docking): Add dynamic lifecycle for external detectors This change introduces an API to dynamically enable and disable external docking detectors, such as those based on AI, to conserve system resources when not actively docking. Key changes: - Added `startDetectionProcess()` and `stopDetectionProcess()` to the docking plugin interface (`ChargingDock` and `NonChargingDock`). - Implemented this logic in `SimpleChargingDock` and `SimpleNonChargingDock` using a `std_srvs/Trigger` service call and dynamic topic subscription to manage the detector's lifecycle. - The `DockingServer` now ensures `stopDetectionProcess()` is called on all exit paths, including success, failure, and cancellation, to prevent dangling resources. - Added new parameters (`detector_service_name`, `subscribe_toggle`, etc.) to configure this behavior and updated the README documentation. - Added comprehensive C++ unit tests to verify the new detector lifecycle logic, specifically covering service failure cases and proper cleanup on action termination. Closes ros-navigation#5015 Signed-off-by: Koensgen Benjamin <[email protected]> - updtae Signed-off-by: Koensgen Benjamin <[email protected]> Signed-off-by: bkoensgen <[email protected]> * fix: Address review feedback and fix unit tests Signed-off-by: Koensgen Benjamin <[email protected]> fix(docking): Change subscribe_toggle default to false Signed-off-by: Koensgen Benjamin <[email protected]> - Signed-off-by: bkoensgen <[email protected]> * refactor(docking): Improve plugin lifecycle and resource management This commit addresses several code review suggestions to improve the design and robustness of the docking plugins. - Replaced the `DetectorState` enum with a simpler `bool detector_enabled_` for clarity. - Encapsulated the detection process lifecycle within the plugin itself. The `deactivate` method now ensures `stopDetectionProcess` is called, improving encapsulation and simplifying the `DockDatabase`. - Refactored the `configure` method in plugins to group related logic, improving readability. - Cleaned up redundant checks and calls in both the plugins and the `DockingServer` for more robust and intentional code. Signed-off-by: Koensgen Benjamin <[email protected]> Signed-off-by: bkoensgen <[email protected]> * fix(plugins): Resolve race condition by setting enabled state in callback The previous refactoring introduced a race condition where the detector was marked as 'enabled' in startDetection() before a message was actually received. This caused tests to fail because getRefinedPose() would be called with an enabled state but no valid/recent data. This commit fixes the issue by moving the `detector_enabled_ = true` assignment into the subscription callback. This ensures the plugin's state accurately reflects that it has received at least one valid data point before being considered active. Signed-off-by: Koensgen Benjamin <[email protected]> Signed-off-by: bkoensgen <[email protected]> * refactor(docking): migrate to nav2_ros_common (node_utils, LifecycleNode, QoS) Signed-off-by: bkoensgen <[email protected]> * build(opennav_docking): update deps (std_srvs, package.xml + CMakeLists) Signed-off-by: bkoensgen <[email protected]> * refactor(Docking): migrate to nav2::LifecycleNode Signed-off-by: bkoensgen <[email protected]> * refactor(docking): use nav2::qos::StandardTopicQoS for subscriptions Signed-off-by: bkoensgen <[email protected]> * refactor(opennav_docking): replace raw queue size with rclcpp::QoS(1) in pubs/subs Signed-off-by: bkoensgen <[email protected]> * refactor(tests): migrate nav2_util::NodeThread to nav2::NodeThread Signed-off-by: bkoensgen <[email protected]> * refactor(tests): migrate to 3-args service callbacks Signed-off-by: bkoensgen <[email protected]> * style(test): apply ament_uncrustify Signed-off-by: bkoensgen <[email protected]> * refactor(opennav_docking) migrate detector Trigger service to node_->create_client() Signed-off-by: bkoensgen <[email protected]> * docking: use nav2 types for pubs/subs in SimpleChargingDock and add explicit detection state flags Signed-off-by: bkoensgen <[email protected]> * docking: use nav2 types for pubs/subs in SimpleNonChargingDock and add explicit detection state flags Signed-off-by: bkoensgen <[email protected]> * docking: split detection state in SimpleChargingDock (detection_started_ vs initial_pose_received_) and warn before first pose Signed-off-by: bkoensgen <[email protected]> * docking: split detection state in SimpleNonChargingDock (detection_started_ vs initial_pose_received_) and warn before first pose Signed-off-by: bkoensgen <[email protected]> * tests: adapt SimpleChargingDockTestable to initial_pose_received_ state Signed-off-by: bkoensgen <[email protected]> * tests: adapt SimpleNonChargingDockTestable to initial_pose_received_ state Signed-off-by: bkoensgen <[email protected]> * docs(docking): clarify external detection gating and subscribe_toggle behavior (default=false) Signed-off-by: bkoensgen <[email protected]> * fix(docking): keep SimpleNonChargingDock registered as ChargingDock (stay in-scope) Signed-off-by: bkoensgen <[email protected]> * docs(docking): revert README note to pre-e881de19 state Signed-off-by: bkoensgen <[email protected]> * fix(docking_server): remove redundant null-check before stopDetectionProcess() in terminal cleanup Signed-off-by: bkoensgen <[email protected]> * style(docking_server): unify terminal order (stash->publishZeroVelocity->stopDetection->terminate) Signed-off-by: bkoensgen <[email protected]> * lint Signed-off-by: bkoensgen <[email protected]> * fix(docking): inline detection process Signed-off-by: bkoensgen <[email protected]> * chore(docking): drop redundant detector comment Signed-off-by: bkoensgen <[email protected]> * chore(docking): clarify detector logs Signed-off-by: bkoensgen <[email protected]> * fix(docking): activate lifecycle publishers Signed-off-by: bkoensgen <[email protected]> * chore(docking): reuse dock pose subscription Signed-off-by: bkoensgen <[email protected]> * lint Signed-off-by: bkoensgen <[email protected]> * fix(docking_server): drop redundant DB deactivate on cleanup Signed-off-by: bkoensgen <[email protected]> * refactor(docking): rename detection state flag to detection_active Signed-off-by: bkoensgen <[email protected]> * fix(docking): reset detection flags on cleanup Signed-off-by: bkoensgen <[email protected]> --------- Signed-off-by: Koensgen Benjamin <[email protected]> Signed-off-by: bkoensgen <[email protected]>
… dock plugins (ros-navigation#5015) (ros-navigation#5218) * feat(opennav_docking): Add dynamic lifecycle for external detectors This change introduces an API to dynamically enable and disable external docking detectors, such as those based on AI, to conserve system resources when not actively docking. Key changes: - Added `startDetectionProcess()` and `stopDetectionProcess()` to the docking plugin interface (`ChargingDock` and `NonChargingDock`). - Implemented this logic in `SimpleChargingDock` and `SimpleNonChargingDock` using a `std_srvs/Trigger` service call and dynamic topic subscription to manage the detector's lifecycle. - The `DockingServer` now ensures `stopDetectionProcess()` is called on all exit paths, including success, failure, and cancellation, to prevent dangling resources. - Added new parameters (`detector_service_name`, `subscribe_toggle`, etc.) to configure this behavior and updated the README documentation. - Added comprehensive C++ unit tests to verify the new detector lifecycle logic, specifically covering service failure cases and proper cleanup on action termination. Closes ros-navigation#5015 Signed-off-by: Koensgen Benjamin <[email protected]> - updtae Signed-off-by: Koensgen Benjamin <[email protected]> Signed-off-by: bkoensgen <[email protected]> * fix: Address review feedback and fix unit tests Signed-off-by: Koensgen Benjamin <[email protected]> fix(docking): Change subscribe_toggle default to false Signed-off-by: Koensgen Benjamin <[email protected]> - Signed-off-by: bkoensgen <[email protected]> * refactor(docking): Improve plugin lifecycle and resource management This commit addresses several code review suggestions to improve the design and robustness of the docking plugins. - Replaced the `DetectorState` enum with a simpler `bool detector_enabled_` for clarity. - Encapsulated the detection process lifecycle within the plugin itself. The `deactivate` method now ensures `stopDetectionProcess` is called, improving encapsulation and simplifying the `DockDatabase`. - Refactored the `configure` method in plugins to group related logic, improving readability. - Cleaned up redundant checks and calls in both the plugins and the `DockingServer` for more robust and intentional code. Signed-off-by: Koensgen Benjamin <[email protected]> Signed-off-by: bkoensgen <[email protected]> * fix(plugins): Resolve race condition by setting enabled state in callback The previous refactoring introduced a race condition where the detector was marked as 'enabled' in startDetection() before a message was actually received. This caused tests to fail because getRefinedPose() would be called with an enabled state but no valid/recent data. This commit fixes the issue by moving the `detector_enabled_ = true` assignment into the subscription callback. This ensures the plugin's state accurately reflects that it has received at least one valid data point before being considered active. Signed-off-by: Koensgen Benjamin <[email protected]> Signed-off-by: bkoensgen <[email protected]> * refactor(docking): migrate to nav2_ros_common (node_utils, LifecycleNode, QoS) Signed-off-by: bkoensgen <[email protected]> * build(opennav_docking): update deps (std_srvs, package.xml + CMakeLists) Signed-off-by: bkoensgen <[email protected]> * refactor(Docking): migrate to nav2::LifecycleNode Signed-off-by: bkoensgen <[email protected]> * refactor(docking): use nav2::qos::StandardTopicQoS for subscriptions Signed-off-by: bkoensgen <[email protected]> * refactor(opennav_docking): replace raw queue size with rclcpp::QoS(1) in pubs/subs Signed-off-by: bkoensgen <[email protected]> * refactor(tests): migrate nav2_util::NodeThread to nav2::NodeThread Signed-off-by: bkoensgen <[email protected]> * refactor(tests): migrate to 3-args service callbacks Signed-off-by: bkoensgen <[email protected]> * style(test): apply ament_uncrustify Signed-off-by: bkoensgen <[email protected]> * refactor(opennav_docking) migrate detector Trigger service to node_->create_client() Signed-off-by: bkoensgen <[email protected]> * docking: use nav2 types for pubs/subs in SimpleChargingDock and add explicit detection state flags Signed-off-by: bkoensgen <[email protected]> * docking: use nav2 types for pubs/subs in SimpleNonChargingDock and add explicit detection state flags Signed-off-by: bkoensgen <[email protected]> * docking: split detection state in SimpleChargingDock (detection_started_ vs initial_pose_received_) and warn before first pose Signed-off-by: bkoensgen <[email protected]> * docking: split detection state in SimpleNonChargingDock (detection_started_ vs initial_pose_received_) and warn before first pose Signed-off-by: bkoensgen <[email protected]> * tests: adapt SimpleChargingDockTestable to initial_pose_received_ state Signed-off-by: bkoensgen <[email protected]> * tests: adapt SimpleNonChargingDockTestable to initial_pose_received_ state Signed-off-by: bkoensgen <[email protected]> * docs(docking): clarify external detection gating and subscribe_toggle behavior (default=false) Signed-off-by: bkoensgen <[email protected]> * fix(docking): keep SimpleNonChargingDock registered as ChargingDock (stay in-scope) Signed-off-by: bkoensgen <[email protected]> * docs(docking): revert README note to pre-e881de19 state Signed-off-by: bkoensgen <[email protected]> * fix(docking_server): remove redundant null-check before stopDetectionProcess() in terminal cleanup Signed-off-by: bkoensgen <[email protected]> * style(docking_server): unify terminal order (stash->publishZeroVelocity->stopDetection->terminate) Signed-off-by: bkoensgen <[email protected]> * lint Signed-off-by: bkoensgen <[email protected]> * fix(docking): inline detection process Signed-off-by: bkoensgen <[email protected]> * chore(docking): drop redundant detector comment Signed-off-by: bkoensgen <[email protected]> * chore(docking): clarify detector logs Signed-off-by: bkoensgen <[email protected]> * fix(docking): activate lifecycle publishers Signed-off-by: bkoensgen <[email protected]> * chore(docking): reuse dock pose subscription Signed-off-by: bkoensgen <[email protected]> * lint Signed-off-by: bkoensgen <[email protected]> * fix(docking_server): drop redundant DB deactivate on cleanup Signed-off-by: bkoensgen <[email protected]> * refactor(docking): rename detection state flag to detection_active Signed-off-by: bkoensgen <[email protected]> * fix(docking): reset detection flags on cleanup Signed-off-by: bkoensgen <[email protected]> --------- Signed-off-by: Koensgen Benjamin <[email protected]> Signed-off-by: bkoensgen <[email protected]>
… dock plugins (ros-navigation#5015) (ros-navigation#5218) * feat(opennav_docking): Add dynamic lifecycle for external detectors This change introduces an API to dynamically enable and disable external docking detectors, such as those based on AI, to conserve system resources when not actively docking. Key changes: - Added `startDetectionProcess()` and `stopDetectionProcess()` to the docking plugin interface (`ChargingDock` and `NonChargingDock`). - Implemented this logic in `SimpleChargingDock` and `SimpleNonChargingDock` using a `std_srvs/Trigger` service call and dynamic topic subscription to manage the detector's lifecycle. - The `DockingServer` now ensures `stopDetectionProcess()` is called on all exit paths, including success, failure, and cancellation, to prevent dangling resources. - Added new parameters (`detector_service_name`, `subscribe_toggle`, etc.) to configure this behavior and updated the README documentation. - Added comprehensive C++ unit tests to verify the new detector lifecycle logic, specifically covering service failure cases and proper cleanup on action termination. Closes ros-navigation#5015 Signed-off-by: Koensgen Benjamin <[email protected]> - updtae Signed-off-by: Koensgen Benjamin <[email protected]> Signed-off-by: bkoensgen <[email protected]> * fix: Address review feedback and fix unit tests Signed-off-by: Koensgen Benjamin <[email protected]> fix(docking): Change subscribe_toggle default to false Signed-off-by: Koensgen Benjamin <[email protected]> - Signed-off-by: bkoensgen <[email protected]> * refactor(docking): Improve plugin lifecycle and resource management This commit addresses several code review suggestions to improve the design and robustness of the docking plugins. - Replaced the `DetectorState` enum with a simpler `bool detector_enabled_` for clarity. - Encapsulated the detection process lifecycle within the plugin itself. The `deactivate` method now ensures `stopDetectionProcess` is called, improving encapsulation and simplifying the `DockDatabase`. - Refactored the `configure` method in plugins to group related logic, improving readability. - Cleaned up redundant checks and calls in both the plugins and the `DockingServer` for more robust and intentional code. Signed-off-by: Koensgen Benjamin <[email protected]> Signed-off-by: bkoensgen <[email protected]> * fix(plugins): Resolve race condition by setting enabled state in callback The previous refactoring introduced a race condition where the detector was marked as 'enabled' in startDetection() before a message was actually received. This caused tests to fail because getRefinedPose() would be called with an enabled state but no valid/recent data. This commit fixes the issue by moving the `detector_enabled_ = true` assignment into the subscription callback. This ensures the plugin's state accurately reflects that it has received at least one valid data point before being considered active. Signed-off-by: Koensgen Benjamin <[email protected]> Signed-off-by: bkoensgen <[email protected]> * refactor(docking): migrate to nav2_ros_common (node_utils, LifecycleNode, QoS) Signed-off-by: bkoensgen <[email protected]> * build(opennav_docking): update deps (std_srvs, package.xml + CMakeLists) Signed-off-by: bkoensgen <[email protected]> * refactor(Docking): migrate to nav2::LifecycleNode Signed-off-by: bkoensgen <[email protected]> * refactor(docking): use nav2::qos::StandardTopicQoS for subscriptions Signed-off-by: bkoensgen <[email protected]> * refactor(opennav_docking): replace raw queue size with rclcpp::QoS(1) in pubs/subs Signed-off-by: bkoensgen <[email protected]> * refactor(tests): migrate nav2_util::NodeThread to nav2::NodeThread Signed-off-by: bkoensgen <[email protected]> * refactor(tests): migrate to 3-args service callbacks Signed-off-by: bkoensgen <[email protected]> * style(test): apply ament_uncrustify Signed-off-by: bkoensgen <[email protected]> * refactor(opennav_docking) migrate detector Trigger service to node_->create_client() Signed-off-by: bkoensgen <[email protected]> * docking: use nav2 types for pubs/subs in SimpleChargingDock and add explicit detection state flags Signed-off-by: bkoensgen <[email protected]> * docking: use nav2 types for pubs/subs in SimpleNonChargingDock and add explicit detection state flags Signed-off-by: bkoensgen <[email protected]> * docking: split detection state in SimpleChargingDock (detection_started_ vs initial_pose_received_) and warn before first pose Signed-off-by: bkoensgen <[email protected]> * docking: split detection state in SimpleNonChargingDock (detection_started_ vs initial_pose_received_) and warn before first pose Signed-off-by: bkoensgen <[email protected]> * tests: adapt SimpleChargingDockTestable to initial_pose_received_ state Signed-off-by: bkoensgen <[email protected]> * tests: adapt SimpleNonChargingDockTestable to initial_pose_received_ state Signed-off-by: bkoensgen <[email protected]> * docs(docking): clarify external detection gating and subscribe_toggle behavior (default=false) Signed-off-by: bkoensgen <[email protected]> * fix(docking): keep SimpleNonChargingDock registered as ChargingDock (stay in-scope) Signed-off-by: bkoensgen <[email protected]> * docs(docking): revert README note to pre-e881de19 state Signed-off-by: bkoensgen <[email protected]> * fix(docking_server): remove redundant null-check before stopDetectionProcess() in terminal cleanup Signed-off-by: bkoensgen <[email protected]> * style(docking_server): unify terminal order (stash->publishZeroVelocity->stopDetection->terminate) Signed-off-by: bkoensgen <[email protected]> * lint Signed-off-by: bkoensgen <[email protected]> * fix(docking): inline detection process Signed-off-by: bkoensgen <[email protected]> * chore(docking): drop redundant detector comment Signed-off-by: bkoensgen <[email protected]> * chore(docking): clarify detector logs Signed-off-by: bkoensgen <[email protected]> * fix(docking): activate lifecycle publishers Signed-off-by: bkoensgen <[email protected]> * chore(docking): reuse dock pose subscription Signed-off-by: bkoensgen <[email protected]> * lint Signed-off-by: bkoensgen <[email protected]> * fix(docking_server): drop redundant DB deactivate on cleanup Signed-off-by: bkoensgen <[email protected]> * refactor(docking): rename detection state flag to detection_active Signed-off-by: bkoensgen <[email protected]> * fix(docking): reset detection flags on cleanup Signed-off-by: bkoensgen <[email protected]> --------- Signed-off-by: Koensgen Benjamin <[email protected]> Signed-off-by: bkoensgen <[email protected]>
Basic Info
colcon test)Description of contribution in a few bullet points
detector_service_name,detector_service_timeout,subscribe_togglestd_srvs/Triggeronly when first neededDescription of documentation updates required
nav2_docking/README.mdDescription of how this change was tested
colcon test --packages-select opennav_docking→ all tests passFor Maintainers