-
Notifications
You must be signed in to change notification settings - Fork 47
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
Fix nested parameter update #210
Conversation
This looks right. I'm a bit worried that it touches the same code that was changed in this PR: #182 __map_joints:
weight: {
type: double,
default_value: 1.0,
description: "Joint weight",
validation: {
gt<>: [ 0.0 ]
}
} |
Okay so I just tested with a mapped parameter as you suggested. supported_things: {
type: string_array,
default_value: ["thing1", "thing2"],
read_only: true,
description: "Things we support",
validation: {
subset_of<>: [ [ "thing1", "thing2"] ],
}
}
__map_supported_things:
super_cool_double_array: {
type: double_array,
default_value: [0.0, 0.0, 0.0],
read_only: true,
description: "The dimensions of our thing",
validation: {
fixed_size<>: 3,
}
} and it generates valid C++ code for (const auto & value_1 : updated_params.supported_things) {
auto& entry = updated_params.supported_things_map[value_1];
std::string value = fmt::format("{}", value_1);
auto param_name = fmt::format("{}{}.{}", prefix_, value, "super_cool_double_array");
if (!parameters_interface_->has_parameter(param_name)) {
rcl_interfaces::msg::ParameterDescriptor descriptor;
descriptor.description = "The dimensions of our thing";
descriptor.read_only = true;
auto parameter = rclcpp::ParameterValue(entry.super_cool_double_array);
parameters_interface_->declare_parameter(param_name, parameter, descriptor);
}
param = parameters_interface_->get_parameter(param_name);
RCLCPP_DEBUG_STREAM(logger_, param.get_name() << ": " << param.get_type_name() << " = " << param.value_to_string());
if(auto validation_result = fixed_size<double>(param, 3);
!validation_result) {
throw rclcpp::exceptions::InvalidParameterValueException(fmt::format("Invalid value set during initialization for parameter '__map_supported_things.super_cool_double_array': {}", validation_result.error()));
}
entry.super_cool_double_array = param.as_double_array();} |
In #185 there were two |
Anything else to wrap up here @pac48? |
@MarqRazz Can you rebase on main now that CI is passing? |
When calling
param_listener.update(override_parameters)
nested parameters will fail to load because of the missing namespace separator.
This PR fixes the template that creates update() function for the parameters with mapped namespaces so that they match & update properly.