From 4eca97998df520052c603eebc3e80c01d5b92e48 Mon Sep 17 00:00:00 2001 From: Patrick Roncagliolo Date: Mon, 9 Dec 2024 09:15:58 +0100 Subject: [PATCH 1/3] Support custom `rclcpp::NodeOptions` This eases static composition of multiple ROS 2 nodes --- .../include/diagnostic_aggregator/aggregator.hpp | 7 +++++++ diagnostic_aggregator/src/aggregator.cpp | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/diagnostic_aggregator/include/diagnostic_aggregator/aggregator.hpp b/diagnostic_aggregator/include/diagnostic_aggregator/aggregator.hpp index 5f48dd6b..ac3e9183 100644 --- a/diagnostic_aggregator/include/diagnostic_aggregator/aggregator.hpp +++ b/diagnostic_aggregator/include/diagnostic_aggregator/aggregator.hpp @@ -111,6 +111,13 @@ class Aggregator DIAGNOSTIC_AGGREGATOR_PUBLIC Aggregator(); + /*! + *\brief Constructor initializes with main prefix (ex: '/Robot') and custom node options + */ + DIAGNOSTIC_AGGREGATOR_PUBLIC + Aggregator(const rclcpp::NodeOptions & options); + + DIAGNOSTIC_AGGREGATOR_PUBLIC virtual ~Aggregator(); diff --git a/diagnostic_aggregator/src/aggregator.cpp b/diagnostic_aggregator/src/aggregator.cpp index 4619ec29..184dfc39 100644 --- a/diagnostic_aggregator/src/aggregator.cpp +++ b/diagnostic_aggregator/src/aggregator.cpp @@ -57,9 +57,12 @@ using diagnostic_msgs::msg::DiagnosticStatus; * @todo(anordman): make aggregator a lifecycle node. */ Aggregator::Aggregator() +: Aggregator(rclcpp::NodeOptions()) {} + +Aggregator::Aggregator(const rclcpp::NodeOptions & options) : n_(std::make_shared( "analyzers", "", - rclcpp::NodeOptions().allow_undeclared_parameters(true). + options.allow_undeclared_parameters(true). automatically_declare_parameters_from_overrides(true))), logger_(rclcpp::get_logger("Aggregator")), pub_rate_(1.0), From e05094a39752acb7db6907e12eb59b6135d61dd5 Mon Sep 17 00:00:00 2001 From: Patrick Roncagliolo Date: Mon, 9 Dec 2024 09:23:58 +0100 Subject: [PATCH 2/3] Fix --- .../include/diagnostic_aggregator/aggregator.hpp | 2 +- diagnostic_aggregator/src/aggregator.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/diagnostic_aggregator/include/diagnostic_aggregator/aggregator.hpp b/diagnostic_aggregator/include/diagnostic_aggregator/aggregator.hpp index ac3e9183..b9235d58 100644 --- a/diagnostic_aggregator/include/diagnostic_aggregator/aggregator.hpp +++ b/diagnostic_aggregator/include/diagnostic_aggregator/aggregator.hpp @@ -115,7 +115,7 @@ class Aggregator *\brief Constructor initializes with main prefix (ex: '/Robot') and custom node options */ DIAGNOSTIC_AGGREGATOR_PUBLIC - Aggregator(const rclcpp::NodeOptions & options); + Aggregator(rclcpp::NodeOptions options); DIAGNOSTIC_AGGREGATOR_PUBLIC diff --git a/diagnostic_aggregator/src/aggregator.cpp b/diagnostic_aggregator/src/aggregator.cpp index 184dfc39..6b60eee3 100644 --- a/diagnostic_aggregator/src/aggregator.cpp +++ b/diagnostic_aggregator/src/aggregator.cpp @@ -59,7 +59,7 @@ using diagnostic_msgs::msg::DiagnosticStatus; Aggregator::Aggregator() : Aggregator(rclcpp::NodeOptions()) {} -Aggregator::Aggregator(const rclcpp::NodeOptions & options) +Aggregator::Aggregator(rclcpp::NodeOptions options) : n_(std::make_shared( "analyzers", "", options.allow_undeclared_parameters(true). From d8aac67dfb8406defb3c5ff5d1a9923ede2538a2 Mon Sep 17 00:00:00 2001 From: Patrick Roncagliolo Date: Tue, 17 Dec 2024 13:56:27 +0100 Subject: [PATCH 3/3] Update aggregator.hpp --- .../include/diagnostic_aggregator/aggregator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diagnostic_aggregator/include/diagnostic_aggregator/aggregator.hpp b/diagnostic_aggregator/include/diagnostic_aggregator/aggregator.hpp index b9235d58..1d2c7e63 100644 --- a/diagnostic_aggregator/include/diagnostic_aggregator/aggregator.hpp +++ b/diagnostic_aggregator/include/diagnostic_aggregator/aggregator.hpp @@ -115,7 +115,7 @@ class Aggregator *\brief Constructor initializes with main prefix (ex: '/Robot') and custom node options */ DIAGNOSTIC_AGGREGATOR_PUBLIC - Aggregator(rclcpp::NodeOptions options); + explicit Aggregator(rclcpp::NodeOptions options); DIAGNOSTIC_AGGREGATOR_PUBLIC