Skip to content

Impossible to tell which parameters were gotten if some don't exist #490

@sloretz

Description

@sloretz

Bug report

Required Info:

  • Operating System:
    • Ubuntu 16.04
  • Installation type:
    • source
  • Version or commit hash:
  • DDS implementation:
    • Fast-RTPS
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

ros2 run demo_nodes_cpp listener

In another terminal

ros2 param set listener bool_param1 true
ros2 param set listener bool_param2 true
ros2 service call /listener/get_parameters rcl_interfaces/GetParameters "{'names': ['bool_param1', 'does_not_exist', 'bool_param2']}"

Expected behavior

I would expect the returned output from the service call to indicate which parameter did not exist

Actual behavior

Response to service call has 2 values, but no indication of which of the 3 requested parameters were returned.

rcl_interfaces.srv.GetParameters_Response(values=[rcl_interfaces.msg.ParameterValue(type=1, bool_value=True, integer_value=0, double_value=0.0, string_value='', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[]), rcl_interfaces.msg.ParameterValue(type=1, bool_value=True, integer_value=0, double_value=0.0, string_value='', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[])])

Additional information

The cause seems to be this code that only adds a result if the parameter exists. One solution might be to add an else case adding a parameter value with type NOT_SET to the result.

if (std::any_of(parameters_.cbegin(), parameters_.cend(),
[&name](const std::pair<std::string, rclcpp::Parameter> & kv) {
return name == kv.first;
}))
{
results.push_back(parameters_.at(name));
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions