D5 – Configure ROS Node – Private Parameters

ROS nodes can be configured by means of ROS parameters. These are stored on ROS parameter server (part of ROS core) – on the server.

There are several possibilities how to setup the ROS node:

  • Set the parameters on the server and start the node
  • Start the node with parameters passed as the command line parameters
  • Start the node with the configuration file (currently not supported)

The first possibility can be handled by the jrosparam (under the jroscore project). Jrosparam is java implementation of rosparam (installed with ROS by default). For more information, run:

cd jroscore

./jrosparam -h

The second possibility is to pass parameters to the ROS node as command line parameters during its startup.

This simple demo shows how to pass parameters to ROS node from the command line. The demo node is located under `demonodes/basic/org.hanns.demonodes.privateParams.SerPrivateParameters’. This node reads the following private parameters:

  • a – integer
  • b – integer
  • shouldLog – boolean defining whether to produce verbose output.

After startup, this node reads these parameters (if not found, sets the default values) and then starts to perform the computation of the following equation: y=a*sin(b*t), this value is published to its output.

Launching the Demo

The node can be started with the following command:

cd demonodes/basic

./runner org.hanns.demonodes.privateParams.SetPrivateParameters _a:=11 _b:=10 _shouldLog:=true __ns:=my/namespace

By running this in a new console:

cd nengoros/jroscore

./jrosparam list

we will obtain list of parameters, each private parameter of a node is located under its name (where name of node is under a namespace) :

------------------------- parameters are:
Param: /my/namespace/SetPrivateParametersNode/b val: 10
Param: /my/namespace/SetPrivateParametersNode/a val: 11
Param: /my/namespace/SetPrivateParametersNode/shouldLog val: true

The resulting ROS network is depicted here: