pass ros param as argument to another param
Hello,
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" />
</node>
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,
~Best
Asked by wintermute on 2020-10-11 11:56:31 UTC
Answers
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" />
</node>
and reading them like explained before.
Hope this helps you.
Regards.
Asked by Weasfas on 2020-10-12 05:19:13 UTC
Comments
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.
Best
Asked by wintermute on 2020-10-12 09:03:04 UTC
@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");
.
Asked by Weasfas on 2020-10-12 11:45:21 UTC
Comments