As far as I'm aware, you can't use launch files to read individual parameters in yaml files and/or change them. You can, however, use an arg
tag to specify a file path and pass the file name to the launch file. For example, let's call the following launch file launch1.launch
:
<launch>
<arg name="file_name" default="$(find my_package)/my_yaml.yaml"/>
<rosparam command="load" file="$(arg file_name)"/>
</launch>
Then you can include
this launch file from other launch files and use the file_name
arg
to dynamically change what yaml file you're using. For example, let's call the following launch file launch2.launch
:
<launch>
<arg name="file_name" default="$(find my_package)/another_yaml.yaml"/>
<include file="$(find my_package)/launch1.launch">
<arg name="file_name" value="$(arg file_name)"/>
</include>
</launch>
This would result in launch1.launch
being used with the yaml file passed to it (another_yaml.yaml
) instead of its default of my_yaml.yaml
.
An alternative approach is to load the yam with out the parameters that you want to change during launch and set those as arguments. Here's launch3.launch
:
<launch>
<arg name="file_name" default="$(find my_package)/my_yaml.yaml"/>
<arg name="param1" default="0"/>
<arg name="param2" default="1"/>
<rosparam command="load" file="$(arg file_name)" />
<param name="param1" value="$(arg param1)"/>
<param name="param2" value="$(arg param2)"/>
</launch>
A good way to get how this all works is to read other projects' launch files and to just experiment (oh, and read the launch file wiki entry too).