Defines an argument (a variable) that can be passed to a launch file via CLI , each argument can have default value.
LaunchConfiguration
LaunchConfiguration represents the value of a launch argument at runtime. It acts as a placeholder or reference to an argument declared with DeclareLaunchArgument
fromlaunchimportLaunchDescriptionfromlaunch.actionsimportDeclareLaunchArgumentfromlaunch.substitutionsimportLaunchConfigurationfromlaunch_ros.actionsimportNodefromlaunch.actionsimportLogInfodefgenerate_launch_description():ld=LaunchDescription()arg1_decalre=DeclareLaunchArgument('arg1',description="simple arg1 for demo",default_value='hello world')arg1=LaunchConfiguration('arg1')log1=LogInfo(msg=["argument demo from cli using subsitution ",arg1])ld.add_action(arg1_decalre)ld.add_action(log1)returnld
# Show launch argumentsros2launchlaunch_tutorialargs_log_demo.launch.py-s
#Arguments(passargumentsas'<name>:=<value>'):
'arg1':
simplearg1fordemo
(default:'hello world')# Get Argument from CLIros2launchlaunch_tutorialargs_log_demo.launch.pyarg1:="data to arg1 from cli"#[INFO][launch.user]:Argument'arg1'value:datatoarg1fromcli