0
$\begingroup$

Rosanswers logo

What is the order that roslaunch parses and loads parameters? I understand that roslaunch doesn't guarantee the order of nodes launched, but are there some guarantees for parameters, specifically related to nodes? Example launch file:

<launch>
  <param name="p1" value="p1" />
  <node pkg="test_node" type="test_node" name="test_node" >
    <param name="p2" value="p2" />
    <rosparam command="load" file="test.yaml" />
    <param name="p3" value="p3" />
  </node>
  <param name="p4" value="p4" />
</launch>

Some specific questions:

  • Are all parameters in the file (and possibly all included launch files) loaded before all the nodes? For example: p1, and p4 loaded before test_node.
  • Are parameters in a node's namespace guaranteed to be loaded before the node is launched? For example: p2, test.yaml and p3 loaded before test_node.
  • If there are multiple parameters with the same name, which one will overwrite the other? For example, if p4 had the same name as p1, which one wins?
  • If a parameter has the same name as one in a yaml file, which will overwrite the other? For example, if p2 or p3 had the same name as a parameter in test.yaml, which one wins?

Originally posted by baxelrod on ROS Answers with karma: 794 on 2014-12-16

Post score: 2

$\endgroup$

1 Answer 1

1
$\begingroup$

Rosanswers logo

I'll answer only a few of your questions directly, the others should be clear from the information on the linked pages.

  • What is the order that roslaunch parses and loads parameters? I understand that roslaunch doesn't guarantee the order of nodes launched, but are there some guarantees for parameters, specifically related to nodes?
  • If there are multiple parameters with the same name, which one will overwrite the other? For example, if p4 had the same name as p1, which one wins?

According to the roslaunch/XML page, section 1. Evaluation order:

roslaunch evaluates the XML file in a single pass. Includes are processed in depth-first traversal order. Tags are evaluated serially and the last setting wins. Thus, if there are multiple settings of a parameter, the last value specified for the parameter will be used. [..]

So, single pass, depth-first, last setting wins. iiuc, this also holds for parameters from yaml files.

  • Are all parameters in the file (and possibly all included launch files) loaded before all the nodes? For example: p1, and p4 loaded before test_node.

According to roslaunch/XML, section 5.3 Setting parameters:

You can also set parameters on the Parameter Server. These parameters will be stored on the Parameter Server before any nodes are launched.

So yes, parameters are read (and pushed) first, then nodes are started. Afaict I would expect this to be the same for included files.

  • If a parameter has the same name as one in a yaml file, which will overwrite the other? For example, if p2 or p3 had the same name as a parameter in test.yaml, which one wins?

From roslaunch/XML/rosparam, section 1. <rosparam> tag:

The load command is considered additive: if you declare a dictionary or namespace of parameters, those parameters will be added to any other parameters declared for that namespace. Similarly, load commands can override parameters previously declared. [..]

If you have any more questions, I'd refer you to the roslaunch/XML and roslaunch wiki pages.


Originally posted by gvdhoorn with karma: 86574 on 2014-12-16

This answer was ACCEPTED on the original site

Post score: 6


Original comments

Comment by Walt Johnson on 2021-02-23:
Can we assume the same holds true if we load two rosparam .yaml files, that parameters from the second file will override parameters of the same name from the first file?

Comment by gvdhoorn on 2021-02-23:
As I commented in #q372578, I believe your question is covered by this:

From roslaunch/XML/rosparam, section 1. <rosparam> tag:

The load command is considered additive: if you declare a dictionary or namespace of parameters, those parameters will be added to any other parameters declared for that namespace. Similarly, load commands can override parameters previously declared. [..]

But as with everything: I'd suggest to test it.

It should not take more than 5 minutes.

Comment by AndyZe on 2023-05-28:
Aren't these two statements contradictory:

The load command is considered additive

Similarly, load commands can override parameters previously declared
$\endgroup$

Your Answer

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