From ebaedb318b37d6561404d0320a5d65a794bfeaef Mon Sep 17 00:00:00 2001 From: Ryan Friedman Date: Tue, 7 May 2024 09:46:20 -0600 Subject: [PATCH] Tools: Expose map/console mavproxy args * These can be set in ros2 launch calls now Signed-off-by: Ryan Friedman --- Tools/ros2/README.md | 8 ++++ .../src/ardupilot_sitl/launch.py | 42 ++++++++++++++----- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/Tools/ros2/README.md b/Tools/ros2/README.md index 9832e412f999d..c6d6504517be1 100644 --- a/Tools/ros2/README.md +++ b/Tools/ros2/README.md @@ -13,6 +13,14 @@ For example `ardurover` SITL may be launched with: ros2 launch ardupilot_sitl sitl.launch.py command:=ardurover model:=rover ``` +Other launch files are included with many arguments. +Some common arguments are exposed and forwarded to the underlying process. + +For example, MAVProxy can be launched, and you can enable the `console` and `map`. +```bash +ros2 launch ardupilot_sitl sitl_mavproxy.launch.py map:=True console:=True +``` + #### `ardupilot_dds_test` A `colcon` package for testing communication between `micro_ros_agent` and the diff --git a/Tools/ros2/ardupilot_sitl/src/ardupilot_sitl/launch.py b/Tools/ros2/ardupilot_sitl/src/ardupilot_sitl/launch.py index 10203e148bf53..a0ea49a58ab6f 100644 --- a/Tools/ros2/ardupilot_sitl/src/ardupilot_sitl/launch.py +++ b/Tools/ros2/ardupilot_sitl/src/ardupilot_sitl/launch.py @@ -286,26 +286,36 @@ def generate_action(context: LaunchContext, *args, **kwargs) -> ExecuteProcess: master = LaunchConfiguration("master").perform(context) out = LaunchConfiguration("out").perform(context) sitl = LaunchConfiguration("sitl").perform(context) + console = LaunchConfiguration("console").perform(context) + map = LaunchConfiguration("map").perform(context) # Display launch arguments. print(f"command: {command}") print(f"master: {master}") print(f"sitl: {sitl}") print(f"out: {out}") + print(f"console: {console}") + print(f"map: {map}") + + cmd = [ + f"{command} ", + f"--out {out} ", + "--out ", + "127.0.0.1:14551 ", + f"--master {master} ", + f"--sitl {sitl} ", + "--non-interactive ", + ] + + if console: + cmd.append("--console ") + + if map: + cmd.append("--map ") # Create action. mavproxy_process = ExecuteProcess( - cmd=[ - [ - f"{command} ", - f"--out {out} ", - "--out ", - "127.0.0.1:14551 ", - f"--master {master} ", - f"--sitl {sitl} ", - "--non-interactive ", - ] - ], + cmd=cmd, shell=True, output="both", respawn=False, @@ -355,6 +365,16 @@ def generate_launch_arguments() -> List[DeclareLaunchArgument]: default_value="127.0.0.1:5501", description="SITL output port.", ), + DeclareLaunchArgument( + "map", + default_value="False", + description="Enable MAVProxy Map.", + ), + DeclareLaunchArgument( + "console", + default_value="False", + description="Enable MAVProxy Console.", + ), ]