ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

roslaunch order of rosparams

asked 2014-12-16 09:14:03 -0600

baxelrod gravatar image

updated 2014-12-16 09:14:25 -0600

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?
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
6

answered 2014-12-16 09:57:34 -0600

gvdhoorn gravatar image

updated 2014-12-16 10:06:58 -0600

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.

edit flag offensive delete link more

Comments

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?

Walt Johnson gravatar image Walt Johnson  ( 2021-02-23 15:13:02 -0600 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2021-02-23 15:18:42 -0600 )edit

Aren't these two statements contradictory:

The load command is considered additive

Similarly, load commands can override parameters previously declared
AndyZe gravatar image AndyZe  ( 2023-05-28 14:51:28 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2014-12-16 09:14:03 -0600

Seen: 2,635 times

Last updated: Dec 16 '14