generate_parameter_library icon indicating copy to clipboard operation
generate_parameter_library copied to clipboard

Support empty parameter list

Open pele1410 opened this issue 1 year ago • 0 comments

My goal is to be able to provide the infrastructure for a parameter library without requiring actual parameters. This could be because I'm stubbing out a class early in development or if I am just wanting to be consistent and provide an easy place for future work to add to.

Something like:

foo::bar_params: []

I would expect then that accessing the params with get_params() returns an empty list:

param_listener_ = std::make_shared<bar_params::ParamListener>(get_node());
params_ = param_listener_->get_params(); 
// params _is an empty list

The current workaround is to provide a dummy value:

foo::bar_params:
  dummy:
    type: int

but this just leads to cruft that I'd rather not have.
I tried to use the none type to not actually generate the dummy param, but this doesn't compile in C++ due to an unused-variable warning.

foo::bar_params:
  dummy:
    type: none
bar_params.hpp: In member function ‘rcl_interfaces::msg::SetParametersResult foo::bar_params::ParamListener::update(const std::vector<rclcpp::Parameter>&)’:
bar_params.hpp:135:24: error: unused variable ‘param’ [-Werror=unused-variable]
  135 |       for (const auto &param: parameters) {

pele1410 avatar Nov 13 '24 13:11 pele1410