0
$\begingroup$

Rosanswers logo

In my understanding, nodes can get initialization arguments in two ways:

  1. rosrun or roslaunch xml files can pass command line arguments straight to the main method
  2. the node can use the ros parameter server to get parameters that have been loaded by rosparam or roslaunch loading a yaml config file.

Are there any benefits to one over the other? Perhaps in terms of performance (I plan to use ROS on embedded devices), flexibility, or some other way I'm not thinking of? Or is there a best practice?

I see a clear case for yaml in the case of things like motor parameters, since you may want to tweak them while the node is running and save the value you ended up with for subsequent runs.

But what about a parameter that will not change during execution such as a parameter that specifies whether a node is left or right handed?

Or what about parameters that are not always used? For example, a node type could be 'tcp' or 'serial.' It then either needs an IP address or a port, but not both.


Originally posted by thebyohazard on ROS Answers with karma: 3562 on 2012-12-06

Post score: 11

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

For parameters that are only processed once at initialization, performance is not an issue. If there are a lot of them to set, YAML files are a good choice. They are easy to read and easy to edit. You can conveniently store them in packages. For a node with only a few parameters, it may be easier to set them in a launch file. The rosrun command line is mostly good when running a node separately for testing or debugging.

Sensible default values help keep things simple. Unused parameters can default to something like an empty string, where appropriate.

The only performance issue is when parameters need to be updated while the node is operating. Use getParamCached() instead of getParam() in that case, to avoid bogging down the parameter server. Or, use the excellent dynamic_reconfigure package, which will invoke a callback in your node whenever a parameter changes.


Originally posted by joq with karma: 25443 on 2012-12-06

This answer was ACCEPTED on the original site

Post score: 10

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.