Skip to content

Commit

Permalink
[rolling] Get user specified parameters at startup (#80) (#82)
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)

Co-authored-by: john-maidbot <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
  • Loading branch information
3 people authored May 24, 2024
1 parent ba47d0f commit a19e2a9
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 a19e2a9

Please sign in to comment.