ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I don't believe you can access the argument during building of the description. I think you can still do what you want though as far as building paths based on an argument by passing in an array and have the path concat'd at run time.
For example, I want to specify the underlying hardware launch file as an argument. If I give the argument hardware:=rpi1 then my main launch file will include launch file rpi1.launch.py in it's launch description:
Import required modules:
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import ThisLaunchFileDir, LaunchConfiguration
Declare the launch argument, then use the launch argument in a build-path statement to include my parameterized launch file:
launch_desc.add_action( launch.actions.DeclareLaunchArgument('hardware', default_value='hardware') )
launch_desc.add_action( IncludeLaunchDescription(PythonLaunchDescriptionSource([ThisLaunchFileDir(),'/',LaunchConfiguration('hardware'), '.launch.py'])) )
2 | No.2 Revision |
I don't believe you can access the argument during building of the description. I think you can still do what you want though as far as building paths based on an argument by passing in an array and have the path concat'd at run time.
For example, I want to specify the underlying hardware launch file as an argument. If I give the argument hardware:=rpi1 hardware:=rpi1 then my main launch file will include launch file rpi1.launch.py rpi1.launch.py instead of the default hardware.launch.py in it's launch description:
Import required modules:
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import ThisLaunchFileDir, LaunchConfiguration
Declare the launch argument, then use the launch argument in a build-path statement to include my parameterized launch file:
launch_desc.add_action( launch.actions.DeclareLaunchArgument('hardware', default_value='hardware') )
launch_desc.add_action( IncludeLaunchDescription(PythonLaunchDescriptionSource([ThisLaunchFileDir(),'/',LaunchConfiguration('hardware'), '.launch.py'])) )