bt_navigator_***_rclcpp_node - Namespacing + NodeOptions forwarding#5310
bt_navigator_***_rclcpp_node - Namespacing + NodeOptions forwarding#5310SteveMacenski merged 2 commits intoros-navigation:mainfrom
bt_navigator_***_rclcpp_node - Namespacing + NodeOptions forwarding#5310Conversation
Closes ros-navigation#5242 Inspired by: ros-navigation#5202 - `bt_navigator_***_rclcpp_node` now gets the same namespace of `bt_navigator` - `bt_navigator_***_rclcpp_node` now gets the same node options of `bt_navigator` (apart from node name, that is still forced to respect the pattern `bt_navigator_***_rclcpp_node` ) Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
... and 8 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
|
|
Yeah, put that in the node_utils file in |
|
@roncapat, your PR has failed to build. Please check CI outputs and resolve issues. |
|
@roncapat please sign off with DCO and I can merge |
There was a problem hiding this comment.
Pull Request Overview
This PR centralizes argument replacement logic and forwards namespace and node options from parent to child nodes.
- Extracts and reuses
replaceOrAddArgumentutility innav2_ros_common - Updates
Costmap2DROSto use the new utility for namespacing anduse_sim_time - Refactors
BtActionServerto forward parent node options instead of reconstructing arguments inline
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| nav2_ros_common/include/nav2_ros_common/node_utils.hpp | Added replaceOrAddArgument helper to manage ROS arguments |
| nav2_costmap_2d/src/costmap_2d_ros.cpp | Removed local copy and wired up nav2::replaceOrAddArgument in getChildNodeOptions |
| nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_ros.hpp | Deleted redundant declaration of replaceOrAddArgument |
| nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp | Refactored action server to pull and modify parent NodeOptions rather than hardcoding args |
Comments suppressed due to low confidence (1)
nav2_ros_common/include/nav2_ros_common/node_utils.hpp:386
- Add unit tests for
replaceOrAddArgumentcovering both the replace and add branches to ensure correct behavior when the argument exists or not.
inline void replaceOrAddArgument(
| auto new_arguments = node->get_node_options().arguments(); | ||
| nav2::replaceOrAddArgument(new_arguments, "-r", "__node", std::string("__node:=") + | ||
| std::string(node->get_name()) + "_" + client_node_name + "_rclcpp_node"); | ||
| auto options = node->get_node_options(); | ||
| options = options.arguments(new_arguments); |
There was a problem hiding this comment.
[nitpick] You could combine fetching and updating NodeOptions into a single expression (e.g., auto options = node->get_node_options().arguments(new_arguments);) to reduce variable shadowing and improve clarity.
| auto new_arguments = node->get_node_options().arguments(); | |
| nav2::replaceOrAddArgument(new_arguments, "-r", "__node", std::string("__node:=") + | |
| std::string(node->get_name()) + "_" + client_node_name + "_rclcpp_node"); | |
| auto options = node->get_node_options(); | |
| options = options.arguments(new_arguments); | |
| auto options = node->get_node_options().arguments( | |
| nav2::replaceOrAddArgument( | |
| node->get_node_options().arguments(), "-r", "__node", std::string("__node:=") + | |
| std::string(node->get_name()) + "_" + client_node_name + "_rclcpp_node")); |
Moved to `nav2_ros_common/node_utils.hpp`, namespace `nav2` Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>
|
@SteveMacenski done :) |
|
Thank you kindly - and merged! |
…ros-navigation#5310) * `bt_navigator_***_rclcpp_node` - Namespacing + NodeOptions forwarding Closes ros-navigation#5242 Inspired by: ros-navigation#5202 - `bt_navigator_***_rclcpp_node` now gets the same namespace of `bt_navigator` - `bt_navigator_***_rclcpp_node` now gets the same node options of `bt_navigator` (apart from node name, that is still forced to respect the pattern `bt_navigator_***_rclcpp_node` ) Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com> * Deduplicate `replaceOrAddArgument` implementation Moved to `nav2_ros_common/node_utils.hpp`, namespace `nav2` Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com> --------- Signed-off-by: Patrick Roncagliolo <ronca.pat@gmail.com>
Closes #5242
Inspired by: #5202
AI generated software: NO
bt_navigator_***_rclcpp_nodenow gets the same namespace ofbt_navigatorbt_navigator_***_rclcpp_nodenow gets the same node options ofbt_navigator(apart from node name, that is still forced to respect the patternbt_navigator_***_rclcpp_node)For Maintainers:
backport-*.