The Parameter Server is a place where variables can be stored, accessed and modified during runtime. The variables are stored as a key-value map, where the key is the name and the value is the stored contents of the variable. ROS uses XMLRPC for the implementation of the Parameter Server and provides APIs to access the parameters. ROS also provides a YAML friendly interface for the user to load and store the parameters on the server. The tool used for interacting with the parameter server is rosparam
. In this tutorial, we must learn about using YAML files for parameter configurations, APIs for C++ and Python to access the parameter server.
The rosparam
tool allows interfacing with the parameter server through a terminal. It allows us to set, get, load, dump, delete and list parameters. Do the following:
roscore
on a terminalrosparam list
to get a list of keys. These are the names of the parameters currently running on the parameter server. The standard parameters that are created when roscore is spawned are shown in the terminal.rosparam get /run_id
. The result will be the value of the parameter. The same can be applied to any parameter.rosparam set /var1 "Value 1"
. This creates a parameter with name (key) as /var1 and "Value 1" as value.rosparam delete /var1
to delete the parameter.YAML is a language that is commonly used for configuration files. It make loading parameters and storing parameters to and from the parameter very simple. The complete language documentation for this language can be found here but whatever you come across in this tutorial is more than enough to get you started.
For this tutorial, refer to the package test_rosyaml on GitHub. Please build it in an active workspace.
Usually, all configuration files are stored in a separate folder named "config". But for this package, the files are stored in a folder named "param_configs". The file shown below is param1.yaml. To load the parameters from a YAML file to the ROS parameter server, we use the command rosparam load
, we can load the parameters using the command:
rosparam load param1.yaml
This will load the parameters on the parameter server. To see the results, run the command rosparam dump
. This command is used to dump the parameters into a specified YAML file. But, if nothing is specified, it prints them out to the terminal.
roscore
. These parameters are loaded by default and all have string as the datatype for values.rosparam dump
for the file param1.yaml (different run, therefore the URI is different from the one above).We use the Node Handler to interact with the parameter server. The docs can be found here. The functions that it provides are follows:
In Python, the parameters are handled through the rospy module. The documentation can be found here. Here are a few functions that it provides: