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:
- whether it's supported or not
- (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>