-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add support for enable_lifecycle_services parameter in LifecycleNode #5307
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
Conversation
Expose the enable_communication_interface parameter from rclcpp_lifecycle::LifecycleNode through nav2's LifecycleNode wrapper. This allows users to disable lifecycle communication interfaces when manually managing node lifecycle transitions. The parameter can be set via NodeOptions parameter overrides: ```cpp rclcpp::NodeOptions options; options.parameter_overrides({{"enable_lifecycle_services", false}}); ``` Fixes #5305 Co-authored-by: Steve Macenski <[email protected]>
Codecov ReportAttention: Patch coverage is
... and 4 files with indirect coverage changes 🚀 New features to boost your workflow:
|
@SteveMacenski thanks! Will check this morning. It may need some fixes due to double call to Anyway, will do some test and apply any required modification, then report to you. |
Tested both ways. Works like a charm!
|
I do not accept the idea of a fake internal node being registered. I've worked hard to make that not occur in the stack! There was once a time we had many internal nodes and now we only have 2 in the 2 exact situations where they make sense (costmap + internal BT node for the BT Nodes to do with as they wish). It would break my soul a little bit to add in a temp node like that 🥲
Edit: I see now that it wouldn't. Does this still work for your needs? Posting a short workflow for how you use it in this PR before we merge would be nice breadcrumb documentation for someone that might want to follow in these steps. |
As I said, works pretty well for me. As I have custom C++ code to load the node, I already make use in various other situation of parameter overrides and I'm fine with it. I too had a situation in the past where I had to deal with temporary nodes, but they are indeed bad by design. However, I may propose in the future a node-less approach for taking in ordinary ROS parameter (I use something similar in other contexts). For the time being, this is performing great :) |
I will try to provide some example code tomorrow :) |
Please! OK I'll wait for that but will plan to merge at that point |
I'll try to summarize down here below the "full picture", since it will be Markdown maybe it could also be added to some repo README if you like. Feel free also to directly edit my comment if you like to apply some touch ups. Nav2 comprises many ROS 2 nodes, all of them being specifically LifecycleNodes. LifecycleNodes share a common interface that allow their current status to be managed externally. LifecycleNodes feature the following management I/Fs:
This means that for every LifecycleNode in the ROS 2 graph, 5 services servers are created. The CLI tool Moreover, in a typical nav2 setup, However, robotic system integrators may require custom setups, with lower involvement of service calls, stricter control on the number of ROS 2 entities on the ROS graph (less nodes, less service endpoints) and maybe also custom lifecycle management strategy. In this case, the lifecycle C++ API could be used instead. Developers can directly calls the appropriate methods to control the lifecycle of the robot. Here's a snippet for creating a LifecycleNode and spinning it in a dedicated executor (this is the so called auto node = std::make_shared<NodeT>(options);
node->configure();
node->activate();
auto node_base = node->get_node_base_interface();
executor = std::make_shared<rclcpp::executors::SingleThreadedExecutor>();
executor->add_node(node_base);
executor->spin();
executor->remove_node(node_base); // Automatic shutdown transition on ctrl-c In this scenario, lifecycle services could be not only superfluous, but an entry point for an user to interfere with the hardcoded lifecycle management logic. However, auto node = std::make_shared<NodeT>(options.parameter_overrides({{"enable_lifecycle_services", false}}));
node->configure();
node->activate();
auto node_base = node->get_node_base_interface();
executor = std::make_shared<rclcpp::executors::SingleThreadedExecutor>();
executor->add_node(node_base);
executor->spin();
executor->remove_node(node_base); // Automatic shutdown transition on ctrl-c Remember: in this way, you will only be able to control the lifecycle node via C++ API calls. Even There's one additional thing to know about nav2 nodes specifically. They use the bond mechanism by default. To disable such mechanism, every nav2 node needs the following parameters to be set (eg. via YAML file with wildcards): /**:
ros__parameters:
bond_heartbeat_period: 0.0
bond_timeout: 0.0 |
…os-navigation#5307) Expose the enable_communication_interface parameter from rclcpp_lifecycle::LifecycleNode through nav2's LifecycleNode wrapper. This allows users to disable lifecycle communication interfaces when manually managing node lifecycle transitions. The parameter can be set via NodeOptions parameter overrides: ```cpp rclcpp::NodeOptions options; options.parameter_overrides({{"enable_lifecycle_services", false}}); ``` Fixes ros-navigation#5305 Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Signed-off-by: orebai <[email protected]>
…os-navigation#5307) Expose the enable_communication_interface parameter from rclcpp_lifecycle::LifecycleNode through nav2's LifecycleNode wrapper. This allows users to disable lifecycle communication interfaces when manually managing node lifecycle transitions. The parameter can be set via NodeOptions parameter overrides: ```cpp rclcpp::NodeOptions options; options.parameter_overrides({{"enable_lifecycle_services", false}}); ``` Fixes ros-navigation#5305 Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
#5300) * fix: Add PushRosNamespace action to navigation launch file and update comments for parameter namespacing Signed-off-by: orebai <[email protected]> * fix: Reorder import statements in navigation launch file for consistency Signed-off-by: orebai <[email protected]> * fix: Correct formatting of comments in navigation launch file for clarity Signed-off-by: orebai <[email protected]> * fix: Add PushRosNamespace action to multiple launch files for parameter namespacing Signed-off-by: orebai <[email protected]> * fix: Add PushRosNamespace action to slam_launch.py for parameter namespacing Signed-off-by: orebai <[email protected]> * Adding logging for matched events and dropped messages into pub/sub of new nav2_ros_common package. Also adding QoS overrides default ON (#5302) * Adding logging for matched events and dropped messages Signed-off-by: Steve Macenski <[email protected]> * toggle on Signed-off-by: Steve Macenski <[email protected]> * apply for smac 2D Signed-off-by: Steve Macenski <[email protected]> * Update interface_factories.hpp Signed-off-by: Steve Macenski <[email protected]> --------- Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: orebai <[email protected]> * Add LaunchConfigAsBool (Fixes #5233) (#5301) * Add LaunchConfigAsBool (Fixes #5233) Signed-off-by: nishalangovender <[email protected]> * Fix Linting Signed-off-by: nishalangovender <[email protected]> * Fix ament_mypy and pre-commit Signed-off-by: nishalangovender <[email protected]> * Added Type Annotations Signed-off-by: Nishalan Govender <[email protected]> * mypy ignore Signed-off-by: Nishalan Govender <[email protected]> * launch.Substitution Signed-off-by: Nishalan Govender <[email protected]> * Update All Bools in nav2_bringup Signed-off-by: Nishalan Govender <[email protected]> --------- Signed-off-by: nishalangovender <[email protected]> Signed-off-by: Nishalan Govender <[email protected]> Signed-off-by: orebai <[email protected]> * Create claude.yml Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: orebai <[email protected]> * Update claude.yml Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: orebai <[email protected]> * Update claude.yml Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: orebai <[email protected]> * Update claude.yml for authorized users Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: orebai <[email protected]> * Update claude.yml Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: orebai <[email protected]> * Update claude.yml Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: orebai <[email protected]> * Adding clear costmap around pose service option (#5309) * Adding clear costmap around pose impl Signed-off-by: Steve Macenski <[email protected]> * Update nav2_msgs/srv/ClearCostmapAroundPose.srv Signed-off-by: Steve Macenski <[email protected]> * Adding APIs for simple commander Signed-off-by: Steve Macenski <[email protected]> * linting Signed-off-by: Steve Macenski <[email protected]> * adding import Signed-off-by: Steve Macenski <[email protected]> --------- Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: orebai <[email protected]> * Add support for enable_lifecycle_services parameter in LifecycleNode (#5307) Expose the enable_communication_interface parameter from rclcpp_lifecycle::LifecycleNode through nav2's LifecycleNode wrapper. This allows users to disable lifecycle communication interfaces when manually managing node lifecycle transitions. The parameter can be set via NodeOptions parameter overrides: ```cpp rclcpp::NodeOptions options; options.parameter_overrides({{"enable_lifecycle_services", false}}); ``` Fixes #5305 Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Signed-off-by: orebai <[email protected]> * fix: Rename PushRosNamespace to PushROSNamespace for consistency across launch files Signed-off-by: orebai <[email protected]> --------- Signed-off-by: orebai <[email protected]> Signed-off-by: Steve Macenski <[email protected]> Signed-off-by: nishalangovender <[email protected]> Signed-off-by: Nishalan Govender <[email protected]> Co-authored-by: orebai <[email protected]> Co-authored-by: Steve Macenski <[email protected]> Co-authored-by: Nishalan Govender <[email protected]> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Expose the enable_communication_interface parameter from rclcpp_lifecycle::LifecycleNode through nav2's LifecycleNode wrapper. This allows users to disable lifecycle communication interfaces when manually managing node lifecycle transitions.
The parameter can be set via NodeOptions parameter overrides:
Fixes #5305
Generated by Claude Sonnet 4