Skip to content

Inconsistent usage of non-numeric validator arguments #287

@sven-hoek

Description

@sven-hoek

I would like to refer to variables that I already have in code (in an underlying driver library) to define bounds of a parameter.

I.e., doing something like this

gain:
    type: double
    default_value: 0.0
    read_only: false
    description: "The amplifier gain in dB"
    validation:
      bounds<>: [device_params::Gain::min, device_params::Gain::max]

In the generated header file, it does work how I want it at the declaration of the parameter: it puts the unquoted arguments there, resulting in properly working code:

descriptor.read_only = false;
descriptor.floating_point_range.resize(1);
descriptor.floating_point_range.at(0).from_value = device_params::Gain::min;
descriptor.floating_point_range.at(0).to_value = device_params::Gain::max;

However, at the validation part of the generated code, it quotes the arguments, leading to compile errors:

param = parameters_interface_->get_parameter(prefix_ + "gain");
RCLCPP_DEBUG_STREAM(logger_, param.get_name() << ": " << param.get_type_name() << " = " << param.value_to_string());
if(auto validation_result = bounds<double>(param, "device_params::Gain::min", "device_params::Gain::max"); validation_result) {
    throw rclcpp::exceptions::InvalidParameterValueException(fmt::format("Invalid value set during initialization for parameter 'gain': {}", validation_result.error()));
}

Could it be an easy fix if it's just the quoting?

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