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

Unexpected behavior for params that exist in the launch file as well as the yaml file

asked 2021-09-27 13:15:26 -0500

jn42 gravatar image

updated 2021-09-27 13:18:33 -0500

I have a .launch.xml file that looks like this (modified from the ros2/demos talker example)

<launch>
  <node pkg="demo_nodes_cpp" exec="talker" output="screen">
    <param from="$(find-pkg-share demo_nodes_cpp)/config/temp.yaml"/>
    <param name="temp_var" value="4"/>
  </node>
  <node pkg="demo_nodes_cpp" exec="listener" output="screen" />
</launch>

And in config/temp.yaml it looks like this

/talker:
  ros__parameters:
    temp_var: 42

When I launch the node using ros2 launch demo_nodes_cpp talker_listener.launch.xml and run ros2 param get talker temp_var I get 42 instead of 4. In ROS1, the launch file param used to override the yaml one. In ROS2, however, it seems that the yaml param takes precedent.

I can get around the issue by simply NOT including the param in the .yaml and only specify it in the .launch file / pass it into the launch file as an argument, but I just wanted to make sure this behavior is expected

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2021-09-27 13:28:32 -0500

osilva gravatar image

updated 2021-09-27 13:31:23 -0500

This is not from the official documentation, but I like how they explain it in this article. Hope this helps:

Source: https://roboticsbackend.com/ros1-vs-r...

So, in ROS1, parameters are handled by the parameter server, which is itself handled by… The ROS master.

In ROS2, no more ROS master = no more (global) parameter server.

The concept of parameters has been completely changed. There is no global parameter anymore. Each parameter is specific to a node.

A node declares and manages its own parameters, and those parameters are destroyed when the node is killed.

It’s like each node has its own parameter server. When you start a node a few ROS2 services are created. Those allow you to interact with its parameters from the terminal or from other nodes.

And this is from more official documentation on yaml: https://docs.ros.org/en/foxy/How-To-G...

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-09-27 13:15:26 -0500

Seen: 136 times

Last updated: Sep 27 '21