From e2b9083e25777df920277ff103b7a027d6362b58 Mon Sep 17 00:00:00 2001 From: Ryan Friedman Date: Wed, 22 May 2024 01:02:25 -0700 Subject: [PATCH] Tools: ros2: Fix plane launch headless * Install models for other users * Fix bool parsing in some launch args --- Tools/ros2/ardupilot_sitl/CMakeLists.txt | 6 ++++++ .../ardupilot_sitl/src/ardupilot_sitl/launch.py | 17 +++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Tools/ros2/ardupilot_sitl/CMakeLists.txt b/Tools/ros2/ardupilot_sitl/CMakeLists.txt index 83a30907c549f..7fc66475e73d2 100644 --- a/Tools/ros2/ardupilot_sitl/CMakeLists.txt +++ b/Tools/ros2/ardupilot_sitl/CMakeLists.txt @@ -99,6 +99,12 @@ install(DIRECTORY DESTINATION share/${PROJECT_NAME}/config/ ) +# Install additional autotest model params. +install(DIRECTORY + ${ARDUPILOT_ROOT}/Tools/autotest/models + DESTINATION share/${PROJECT_NAME}/config/ +) + # Install Python package. ament_python_install_package(${PROJECT_NAME} PACKAGE_DIR src/${PROJECT_NAME} diff --git a/Tools/ros2/ardupilot_sitl/src/ardupilot_sitl/launch.py b/Tools/ros2/ardupilot_sitl/src/ardupilot_sitl/launch.py index a0ea49a58ab6f..12b7009df90f3 100644 --- a/Tools/ros2/ardupilot_sitl/src/ardupilot_sitl/launch.py +++ b/Tools/ros2/ardupilot_sitl/src/ardupilot_sitl/launch.py @@ -31,6 +31,9 @@ from .actions import ExecuteFunction +TRUE_STRING = "True" +FALSE_STRING = "False" +BOOL_STRING_CHOICES = set([TRUE_STRING, FALSE_STRING]) class VirtualPortsLaunch: """Launch functions for creating virtual ports using `socat`.""" @@ -307,10 +310,10 @@ def generate_action(context: LaunchContext, *args, **kwargs) -> ExecuteProcess: "--non-interactive ", ] - if console: + if console == TRUE_STRING: cmd.append("--console ") - if map: + if map == TRUE_STRING: cmd.append("--map ") # Create action. @@ -369,11 +372,13 @@ def generate_launch_arguments() -> List[DeclareLaunchArgument]: "map", default_value="False", description="Enable MAVProxy Map.", + choices=BOOL_STRING_CHOICES ), DeclareLaunchArgument( "console", default_value="False", description="Enable MAVProxy Console.", + choices=BOOL_STRING_CHOICES ), ] @@ -419,12 +424,12 @@ def generate_action(context: LaunchContext, *args, **kwargs) -> ExecuteProcess: # Optional arguments. wipe = LaunchConfiguration("wipe").perform(context) - if wipe == "True": + if wipe == TRUE_STRING: cmd_args.append("--wipe ") print(f"wipe: {wipe}") synthetic_clock = LaunchConfiguration("synthetic_clock").perform(context) - if synthetic_clock == "True": + if synthetic_clock == TRUE_STRING: cmd_args.append("--synthetic-clock ") print(f"synthetic_clock: {synthetic_clock}") @@ -586,13 +591,13 @@ def generate_launch_arguments() -> List[DeclareLaunchArgument]: "wipe", default_value="False", description="Wipe eeprom.", - choices=["True", "False"], + choices=BOOL_STRING_CHOICES, ), DeclareLaunchArgument( "synthetic_clock", default_value="False", description="Set synthetic clock mode.", - choices=["True", "False"], + choices=BOOL_STRING_CHOICES, ), DeclareLaunchArgument( "home",