Ask Your Question

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

asked 2020-07-30 14:38:43 -0500

naegling77 gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-07-30 18:49:19 -0500

Geoff gravatar image

updated 2020-07-30 19:23:15 -0500

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}'

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-07-30 14:38:43 -0500

Seen: 16 times

Last updated: Jul 30