Load yaml parameters conditionally in python launch file
I would like to use a launch parameter to decide whether to load a yaml file, or chose which yaml to load if I have many configuration
For example in ROS1 it would be possible to write something like this:
<arg name="load_config_X" default="true"/>
<arg name="config_type" default="config_A"/>
<node ...>
<rosparam if="$(eval arg('load_config_X') == True)" command="load" file="..." />
<rosparam if="$(eval arg('config_type') == 'config_A') " command="load" file="..." />
<rosparam if="$(eval arg('config_type') == 'config_B') " command="load" file="..." />
</node>
Is there any equivalent to this in ROS2 python files?
load_config_X = DeclareLaunchArgument("load_config_X", default_value=False)
config_type = DeclareLaunchArgument("config_type", default_value='config_A')
my_node = Node(
package='my_pkg',
name='my_node',
executable='my_node',
parameters=[
# ???
# os.path.join('path', 'to', 'config_X.yaml'),
# os.path.join('path', 'to', 'config_A.yaml'),
]
)