Skip to content

Commit

Permalink
Make order of derived parameters independent of CLI arguments
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wentasah authored and m-dahl committed Apr 29, 2024
1 parent e9f375e commit 6f02234
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion r2r/src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6f02234

Please sign in to comment.