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

roslaunch ros2 equivalent to 'rosparam command="load"'

asked 2020-09-29 12:39:06 -0600

updated 2020-09-29 13:33:05 -0600

What is the ros2 equivalent to '<rosparam cmd="load" ..=""/>'?

Looks like there are three possible cases:

  • loading parameters in the root of the parameter server
  • loading parameters privately into a node
  • loading parameters in a "group namespace"

For example, how would you translate the following ROS1 roslaunch file that contains these three cases?

<launch>
   <rosparam command="load" file="$(find mypackage)/config/config.yaml" />

   <node pkg="mypackage" name="mynode" type="mynode">
        <rosparam command="load" file="$(find mypackage)/config/node_config.yaml" />
   </node>

  <group ns="myns"/>
        <rosparam command="load" file="$(find mypackage)/config/node_config.yaml" />
  </group>
</launch>
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2020-10-05 11:39:06 -0600

jacobperron gravatar image

updated 2020-10-20 12:38:41 -0600

Try:

<param from="$(find-pkg-share mypackage)/path/to/params.yaml" />

See the migration guide for launch

edit flag offensive delete link more

Comments

It is weird. You are right about the migration guide. But I am still getting a python launch error. This is my example:

<launch>
<node pkg="mypkg" exec="mynode" name="mypkg">
    <param from="$(find mypkg)/config/mynode_config.yaml"/>
</node>    
</launch>

It is interesting, if I use the rosparam xml tag (instead of param) it does not fail (no matter if I use the attribute "from" or "file"), but parameter values do not seem to load. I also double checked that there the configuration file is in install/share/mypkg/config/mynode_config.yaml.

So by the moment I don't know what it is happening.

Pablo Iñigo Blasco gravatar image Pablo Iñigo Blasco  ( 2020-10-07 14:22:42 -0600 )edit

I think in many scenarios "unknown" tags like <rosparam> are silently ignored; hence parameter values not loading.

Can you share the Python error that you see? Note, the find substitution has been replaced by find-pkg-share, I guess that is responsible for the error.

jacobperron gravatar image jacobperron  ( 2020-10-07 16:00:30 -0600 )edit
0

answered 2023-04-28 13:39:56 -0600

130s gravatar image

OP didn't ask so, but Python format version of answer might be FAQ, so I post here.

Galactic onward, dumping a set of Parameters defined in a .yaml via launch is possible by launch_ros.parameter_descriptions.ParameterFile. Galactic's migration describes it well (docs.ros.org) but posting an example too:

import launch
import launch_ros.parameter_descriptions
import launch_ros.actions

def generate_launch_description():
    return launch.LaunchDescription([
        launch_ros.actions.Node(
            package='demo_nodes_cpp',
            executable='parameter_blackboard',
            parameters=[
                launch_ros.parameter_descriptions.ParameterFile(
                    param_file='parameter_file_with_substitutions.yaml',
                    allow_substs=True)
            ]
        )
    ])
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-09-29 12:39:06 -0600

Seen: 2,080 times

Last updated: Apr 28 '23