[ROS2] How to pass a launch argument into if
I made a launch file like this:
def generate_launch_description():
set_flag = launch.substitutions.LaunchConfiguration('set', default='False')
a = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join( 'a.py')))
b = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join( 'b.py')))
if set_flag == True:
launch_ = launch.LaunchDescription([a,b])
else:
launch_ = launch.LaunchDescription([a])
return launch.LaunchDescription([
launch.actions.DeclareLaunchArgument(name='set', default_value = set_flag,
description='launch or not'),
launch_
])
The if
section always lead it to else
phase whatever I put in command line. Seems I passed argument in a wrong way. How to do it properly?