Skip to content

Commit

Permalink
[rolling] Get user specified parameters at startup (#80)
Browse files Browse the repository at this point in the history
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
(cherry picked from commit 90c603a)
  • Loading branch information
john-maidbot authored and mergify[bot] committed May 13, 2024
1 parent c6b7568 commit 6806bfb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,16 @@ class SimplePublisherPlugin : public point_cloud_transport::PublisherPlugin

//! template function for getting parameter of a given type
template<typename T>
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ class SimpleSubscriberPlugin : public SubscriberPlugin
return {};
}

//! template function for getting parameter of a given type
template<typename T>
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<typename T>
bool declareParam(
const std::string parameter_name, const T value,
Expand Down

0 comments on commit 6806bfb

Please sign in to comment.