From ba90ef41dc9ab01205e5344afb3a320c2046a533 Mon Sep 17 00:00:00 2001 From: Dominic Reber Date: Tue, 24 Oct 2023 07:34:38 +0000 Subject: [PATCH] Avoid conflict with get_parameter (#42) * Hide get_parameter * Hide get_parameter again * 2.2.13 -> 2.2.14 * Update CHANGELOG --- CHANGELOG.md | 1 + .../include/modulo_components/Component.hpp | 7 +++++++ .../include/modulo_components/LifecycleComponent.hpp | 7 +++++++ source/modulo_components/src/Component.cpp | 5 +++++ source/modulo_components/src/LifecycleComponent.cpp | 5 +++++ 5 files changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bacdef683..ef60d10d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Release Versions: ## Upcoming changes (in development) +- Avoid conflict with get_parameter (#42) - Revise ComponentInterface by moving implementations to source file (#39) - Update component classes to inherit from new ComponentInterface (#38) - Refactor ComponentInterface to use node interfaces (#33) diff --git a/source/modulo_components/include/modulo_components/Component.hpp b/source/modulo_components/include/modulo_components/Component.hpp index 2b56251d0..f382fa5c8 100644 --- a/source/modulo_components/include/modulo_components/Component.hpp +++ b/source/modulo_components/include/modulo_components/Component.hpp @@ -37,6 +37,11 @@ class Component : public rclcpp::Node, public ComponentInterface { virtual ~Component() = default; protected: + /** + * @copydoc ComponentInterface::get_parameter + */ + [[nodiscard]] std::shared_ptr get_parameter(const std::string& name) const; + /** * @brief Start the execution thread. */ @@ -76,6 +81,7 @@ class Component : public rclcpp::Node, public ComponentInterface { void on_execute(); // TODO hide ROS methods + using ComponentInterface::get_parameter; using ComponentInterface::create_output; using ComponentInterface::inputs_; using ComponentInterface::outputs_; @@ -84,6 +90,7 @@ class Component : public rclcpp::Node, public ComponentInterface { using ComponentInterface::publish_predicates; using ComponentInterface::publish_outputs; using ComponentInterface::evaluate_periodic_callbacks; + using rclcpp::Node::get_parameter; std::thread execute_thread_; ///< The execution thread of the component bool started_; ///< Flag that indicates if execution has started or not diff --git a/source/modulo_components/include/modulo_components/LifecycleComponent.hpp b/source/modulo_components/include/modulo_components/LifecycleComponent.hpp index 84d3539f4..13fde1616 100644 --- a/source/modulo_components/include/modulo_components/LifecycleComponent.hpp +++ b/source/modulo_components/include/modulo_components/LifecycleComponent.hpp @@ -45,6 +45,11 @@ class LifecycleComponent : public rclcpp_lifecycle::LifecycleNode, public Compon virtual ~LifecycleComponent() = default; protected: + /** + * @copydoc ComponentInterface::get_parameter + */ + [[nodiscard]] std::shared_ptr get_parameter(const std::string& name) const; + /** * @brief Steps to execute when configuring the component. * @details This method can be overridden by derived Component classes. @@ -256,6 +261,7 @@ class LifecycleComponent : public rclcpp_lifecycle::LifecycleNode, public Compon bool clear_signals(); // TODO hide ROS methods + using ComponentInterface::get_parameter; using ComponentInterface::create_output; using ComponentInterface::inputs_; using ComponentInterface::outputs_; @@ -264,6 +270,7 @@ class LifecycleComponent : public rclcpp_lifecycle::LifecycleNode, public Compon using ComponentInterface::publish_predicates; using ComponentInterface::publish_outputs; using ComponentInterface::evaluate_periodic_callbacks; + using rclcpp_lifecycle::LifecycleNode::get_parameter; }; template diff --git a/source/modulo_components/src/Component.cpp b/source/modulo_components/src/Component.cpp index 61a08fb17..9eddba777 100644 --- a/source/modulo_components/src/Component.cpp +++ b/source/modulo_components/src/Component.cpp @@ -56,4 +56,9 @@ void Component::on_execute() { bool Component::on_execute_callback() { return true; } + +std::shared_ptr +Component::get_parameter(const std::string& name) const { + return ComponentInterface::get_parameter(name); +} }// namespace modulo_components diff --git a/source/modulo_components/src/LifecycleComponent.cpp b/source/modulo_components/src/LifecycleComponent.cpp index bbb119d94..0695b93f4 100644 --- a/source/modulo_components/src/LifecycleComponent.cpp +++ b/source/modulo_components/src/LifecycleComponent.cpp @@ -34,6 +34,11 @@ LifecycleComponent::LifecycleComponent(const rclcpp::NodeOptions& node_options, }); } +std::shared_ptr +LifecycleComponent::get_parameter(const std::string& name) const { + return ComponentInterface::get_parameter(name); +} + void LifecycleComponent::step() { try { if (this->get_predicate("is_active")) {