Skip to content

Commit

Permalink
Tools: ros2: Fix plane launch headless
Browse files Browse the repository at this point in the history
* Install models for other users
* Fix bool parsing in some launch args
  • Loading branch information
Ryan Friedman authored and peterbarker committed May 25, 2024
1 parent ead48b6 commit 8a58aff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
6 changes: 6 additions & 0 deletions Tools/ros2/ardupilot_sitl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
17 changes: 11 additions & 6 deletions Tools/ros2/ardupilot_sitl/src/ardupilot_sitl/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`."""
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
),
]

Expand Down Expand Up @@ -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}")

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 8a58aff

Please sign in to comment.