Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jazzy] Get user specified parameters at startup (backport #80) #82

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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