Skip to content

Support empty parameter list #227

Open
@pele1410

Description

@pele1410

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) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions