ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
It is not currently possible to write a parameters YAML file that does not include the node's name.
However, there is a very recent pull request that added functionality to launch_ros
so that parameters can be specified in the launch file. If the node's name/namespace is modified in the launch file, that will be taken into account.
This feature has been implemented but not yet released; it will be included (with more documentation) in the Crystal release at the end of 2018. If you would like to use the functionality in the meantime, you can build ROS 2 from source using the 'master' branches as described here. This is an example of the usage today (syntax and naming may change in the future).
import os
from launch import LaunchDescription
from launch.substitutions import EnvironmentVariable
import launch_ros.actions
def generate_launch_description():
os.environ['MY_ENV_VAR'] ='my_env_value'
return LaunchDescription([
launch_ros.actions.Node(
package='demo_nodes_cpp', node_executable='talker', node_name='my_talker', node_namespace='my_ns',
output='screen',
parameters=[
{'my_param': EnvironmentVariable(name='MY_ENV_VAR')},
],
log_cmd=True,
),
])