0
$\begingroup$

Rosanswers logo

Hello, I've used parameter overrides in ROS1. It's useful if we can use it in ROS2 as well. http://wiki.ros.org/roslaunch/Tutorials/Roslaunch%20tips%20for%20larger%20projects

So I'd like to know:

  1. whether it's supported or not
  2. (if not supported) is it possible to implement it using Python launch API

As for 2, I think it's possible if we can:

  • iterate all actions defined in previous contexts
  • filter action by some conditions
  • override filtered action's attribute

It's similar to what I asked in #q375384. Is it possible to do such a thing?


Originally posted by Kenji Miyake on ROS Answers with karma: 307 on 2021-04-04

Post score: 1


Original comments

Comment by Kenji Miyake on 2021-04-04:
As a workaround, I periodically update parameters like this, but I know it's not a good way...

sample.launch.xml

<launch>
    <include file="my_launch.launch.xml" />
    <include file="parameter_overrides.launch.py" />
</launch>

parameter_overrides.launch.py

from launch import LaunchDescription
from launch.actions import ExecuteProcess
def override(node, param, value):
    return ExecuteProcess(
        cmd=['watch', '-n10', 'ros2', 'param', 'set', node, param, value],
        output='screen',
    )
def generate_launch_description():
    return LaunchDescription([
        override('node', 'param', 'true'),
    ])

Comment by shonigmann on 2021-04-05:
I'm not sure I 100% understand your question, and this may depend on your version of ROS2, but the following may be helpful:

In ROS2, parameters can be set in yaml files and can be scoped to specific nodes (e.g. from https://roboticsbackend.com/ros2-yaml-params/)

/node_1:
  ros__parameters:
    some_text: "abc"
/node_2:
  ros__parameters:
    int_number: 27
    float_param: 45.2
/node_3:
  ros__parameters:
    int_number: 45

To me, this feels like what you are looking for... You can also set generic parameters (that would apply to all nodes) by using ** instead of the node name, e.g.:

/**
  ros__parameters:
    int_number: 5

You can also set parameters directly from the commandline (see here) using ros2 param set <node name> <parameter name> <value>

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Global parameters overrides are not supported, no. They cannot be implemented like roslaunch did, there's no parameter aggregation happening in launch (there cannot be, some actions may not be executed until some event occurs in runtime). You'd have to traverse and monkey patch your launch description before execution. Not ideal.

Doing it in runtime like you do above is probably your only option right now. Perhaps, the Node action could be changed to abide to some global configuration and ignore any locally set parameter. It's a bit controversial, but you could try to pitch it in ros2/launch_ros.


Originally posted by hidmic with karma: 121 on 2021-04-05

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Kenji Miyake on 2021-04-05:
Thank you, I'll learn more and consider how to solve this problem.

$\endgroup$

Your Answer

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