ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
A partially working solution for my particular case is to put default parameters in a yaml file, and include this file from all launch files. I have no more launch file hierarchy: they all launch the OCU directly. However, each launch file overrides the appropriate parameters and adds new ones. I get such a structure:
<!-- This launch file is used for the UAV -->
<launch>
<node name="$(anon ocu)" pkg="ocu" type="OCU" output="screen">
<!-- Loads the OCU default parameters -->
<rosparam command="load" file="$(find ocu)/launchers/ocu.yaml"/>
<!-- Redefines and adds parameters -->
<param name="showUAVCams" value="true"/>
<param name="show3DMap" type="bool" value="true"/>
<param name="robotType" type="string" value="UAV"/>
<!-- These ones are necessary until they are placed in the yaml file -->
<param name="ugv3DModelDescription" textfile="$(find ocu)/media/robot_model/NIFTi.urdf" />
<param name="folderNameForSnapshots" value="$(find ocu)/snapshots" />
</node>
</launch>
As you can see, it does not yet completely work because my parameters with commands cannot be placed in the yaml file directly. I need to investigate more on that.
2 | Added another solution based on a suggestion from dornhege |
A partially working solution for my particular case is to put default parameters in a yaml file, and include this file from all launch files. I have no more launch file hierarchy: they all launch the OCU directly. However, each launch file overrides the appropriate parameters and adds new ones. I get such a structure:
<!-- This launch file is used for the UAV -->
<launch>
<node name="$(anon ocu)" pkg="ocu" type="OCU" output="screen">
<!-- Loads the OCU default parameters -->
<rosparam command="load" file="$(find ocu)/launchers/ocu.yaml"/>
<!-- Redefines and adds parameters -->
<param name="showUAVCams" value="true"/>
<param name="show3DMap" type="bool" value="true"/>
<param name="robotType" type="string" value="UAV"/>
<!-- These ones are necessary until they are placed in the yaml file -->
<param name="ugv3DModelDescription" textfile="$(find ocu)/media/robot_model/NIFTi.urdf" />
<param name="folderNameForSnapshots" value="$(find ocu)/snapshots" />
</node>
</launch>
As you can see, it does not yet completely work because my parameters with commands cannot be placed directly interpreted in the yaml file.
Another partially working solution is to create a homologous argument for each parameter.
There is first a base launch file:
<!-- ocu_base.launch -->
<launch>
<!-- Here all arguments must be declared and their default values given -->
<arg name="_imageTransportMode" default="theora"/>
<arg name="_showArmControlPanel" default="false"/>
<arg name="_robotType" default="UGV"/>
<arg name="_ugv3DModelDescription" default="" />
...
<node name="$(anon ocu)" pkg="ocu" type="OCU" output="screen">
<!-- Here I map the parameters to take the values of the arguments -->
<param name="imageTransportMode" type="string" value="$(arg _imageTransportMode)"/>
<param name="showArmControlPanel" type="bool" value="$(arg _showArmControlPanel)"/>
<param name="robotType" type="string" value="$(arg _robotType)"/>
<param name="ugv3DModelDescription" textfile="$(arg _ugv3DModelDescription)" />
...
</node>
</launch>
And several robot-specific launch files:
<!-- ocu_uav.launch -->
<launch>
<!-- Launches the OCU with default parameters -->
<include file="$(find ocu)/launchers/ocu_base.launch">
<arg name="_imageTransportMode" value="raw"/>
<arg name="_robotType" value="UAV"/>
</include>
</launch>
The problem that I still have is that not all parameters are necessary in all robot-specific files. For example, in the case of the UAV, we do not have a URDF robot model. With standard parameters, I would simply not include the parameter ugv3DModelDescription
at all. With arguments, I MUST give a value. I tried giving a blank string as the default argument, but then the parameter ugv3DModelDescription
tries to load the text file directly. I need to investigate more on that."blank" and roslaunch fails.