# Is it possible to set multiple parameters in ros2 from the command line using "ros2 param set"?

I have two sets of parameters, position and orientation. Each of them are defined as hash maps (definition shown below).

position has 3 components: x, y, z.

orientation has 3 components: roll, pitch, yaw.

I have default values set for them. but I want to change these values from the command line during runtime, using the ros2 set param command from the terminal. Is this possible?

## Code snippet of my parameters

std::map<std::string, double> position_values{
{"x", 1.0},
{"y", 2.0},
{"z", 3.0}
};
this->declare_parameters("position", position_values);


A similar definition is present for orientation as well.

edit retag close merge delete

Sort by » oldest newest most voted

You can't set multiple parameters with one invocation of ros2 param set. You need to call it once for each parameter you want to set. If you need to change multiple parameters without your node doing something in between each parameter being changed, you should use a managed life cycle node (see here for a demo). Deactive the node so that it stops executing, change all the parameters, then re-activate it again.

You can set multiple values within a single parameter when that parameter is a structure. You have to specify the parameter value on the command line using yaml. For example:

 ros2 param set /listener position '1.0, 2.0, 3.0}' 

more