ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

pass ros param as argument to another param

asked 2020-10-11 11:56:31 -0500

wintermute gravatar image


On my launch file I have a:

<rosparam command="load" file="$(find myrobot)/config/robot.yaml" />

statement which loads the parameters from my yaml file. again I have a node like:

<node name="controller" pkg="pid" type="controller" ns="left_wheel" output="screen" >
   <param name="Kp" value="4.8" />
    <param name="Ki" value="3.2" />
    <param name="Kd" value="0.02" />

how can i make the second statement, take arguments from the yaml file. in the yaml file I have my parameters as /myrobot/params/kP ... etc, and I need to pass those parameters as an argument to the node config.

Any ideas greatly appreciated,


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-10-12 05:19:13 -0500

Weasfas gravatar image

His @wintermute,

For this to work you will need to use the ROS parameter server.

For the node to be able to access those parameters you can do several things:

1) Either you process the parameters as public parameters; this is done by using the <rosparam command="load" file="$(find myrobot)/config/robot.yaml" /> command and then retrieving those param in the node as public params with functions like nh.getParam("param_name", param).

2) Or process those parameters as private ones by passing directly the config file to the node.

<node name="controller" pkg="pid" type="controller" ns="left_wheel" output="screen" >
 <rosparam command="load" file="$(find myrobot)/config/robot.yaml" />

and reading them like explained before.

Hope this helps you.


edit flag offensive delete link more


Hi @Weasfas,

is it possible to remap parameters? If it was possible to remap from /mybot/kP to /left_wheel/controller/kP I would be set.


wintermute gravatar image wintermute  ( 2020-10-12 09:03:04 -0500 )edit

@wintermute There is no posibility to remap a parameter. If you want to change from one parameter name to another you will need to delete it from the param server using rosparam delete and then load/ set again your updated parameter with rosparam load/rosparam set. Load is for files and set is for individual parameters and those are command line tools. Besides you can also use these directives programatically in roscpp with nh.setParam("param_name", param); and nh.deleteParam("param_name");.

Weasfas gravatar image Weasfas  ( 2020-10-12 11:45:21 -0500 )edit

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-10-11 11:56:31 -0500

Seen: 514 times

Last updated: Oct 12 '20