ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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
1

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

Comments

A very minor correction, to avoid a copy-paste error, there's a { missing :)

abhishek47 gravatar image abhishek47  ( 2021-05-06 13:41:35 -0500 )edit

Question Tools

2 followers

Stats

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

Seen: 1,113 times

Last updated: Jul 30 '20