From a19e2a9f0ca3cf1765d9f7c448b41baffcd9044c Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 14:13:11 +0200 Subject: [PATCH] [rolling] Get user specified parameters at startup (#80) (#82) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alejandro Hernández Cordero (cherry picked from commit 90c603a1e8fb56c3203ff6870e4f2205c37e59b4) Co-authored-by: john-maidbot <78750993+john-maidbot@users.noreply.github.com> Co-authored-by: Alejandro Hernández Cordero --- .../simple_publisher_plugin.hpp | 10 ++++++++-- .../simple_subscriber_plugin.hpp | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/point_cloud_transport/include/point_cloud_transport/simple_publisher_plugin.hpp b/point_cloud_transport/include/point_cloud_transport/simple_publisher_plugin.hpp index 3d3531f..38d2ad1 100644 --- a/point_cloud_transport/include/point_cloud_transport/simple_publisher_plugin.hpp +++ b/point_cloud_transport/include/point_cloud_transport/simple_publisher_plugin.hpp @@ -91,10 +91,16 @@ class SimplePublisherPlugin : public point_cloud_transport::PublisherPlugin //! template function for getting parameter of a given type template - bool getParam(const std::string & name, T & value) const + bool getParam(const std::string & parameter_name, T & value) const { if (simple_impl_) { - return simple_impl_->node_->get_parameter(name, value); + uint ns_len = simple_impl_->node_->get_effective_namespace().length(); + std::string param_base_name = getTopic().substr(ns_len); + std::replace(param_base_name.begin(), param_base_name.end(), '/', '.'); + + std::string param_name = param_base_name + "." + parameter_name; + + return simple_impl_->node_->get_parameter(param_name, value); } return false; } diff --git a/point_cloud_transport/include/point_cloud_transport/simple_subscriber_plugin.hpp b/point_cloud_transport/include/point_cloud_transport/simple_subscriber_plugin.hpp index 1b77585..a4958ff 100644 --- a/point_cloud_transport/include/point_cloud_transport/simple_subscriber_plugin.hpp +++ b/point_cloud_transport/include/point_cloud_transport/simple_subscriber_plugin.hpp @@ -87,6 +87,22 @@ class SimpleSubscriberPlugin : public SubscriberPlugin return {}; } + //! template function for getting parameter of a given type + template + bool getParam(const std::string & parameter_name, T & value) const + { + if (impl_) { + uint ns_len = impl_->node_->get_effective_namespace().length(); + std::string param_base_name = getTopic().substr(ns_len); + std::replace(param_base_name.begin(), param_base_name.end(), '/', '.'); + + std::string param_name = param_base_name + "." + parameter_name; + + return impl_->node_->get_parameter(param_name, value); + } + return false; + } + template bool declareParam( const std::string parameter_name, const T value,