Make order of derived parameters independent of CLI arguments

The previous commit made the order of parameters deterministic
(defined by so called insertion order), but the order still depends on
whether or not some parameters were set from the command line. Command
line parameters are inserted to the IndexMap at Node creation time,
while other RosParams-derived parameters later, during the call to
make_derived_parameter_handler().

This commit ensures that parameters processed by
make_derived_parameter_handler() are always inserted in the same
order, even if some of them were already inserted before due to CLI
arguments.
This commit is contained in:
Michal Sojka 2024-04-28 19:46:35 +02:00 committed by Martin Dahl
parent e9f375e8f6
commit 6f02234c69
1 changed files with 3 additions and 1 deletions

View File

@ -209,8 +209,10 @@ macro_rules! impl_ros_params {
// Apply parameter value if set from command line or launch file
self.set_parameter("", &cli_param.value)
.map_err(|e| e.update_param_name(prefix))?;
// Remove the parameter (will be re-inserted below with deterministic order)
params.shift_remove(prefix);
}
// Insert (or replace) the parameter with filled-in description etc.
// Insert the parameter with filled-in description etc.
let mut param = param.unwrap();
param.value = $param_value_type($to_param_conv(self)?);
params.insert(prefix.to_owned(), param);