From 051c2dcd3554f1baa597dcc79220bf35f0fb37bd Mon Sep 17 00:00:00 2001 From: Henry Wurzburg Date: Fri, 6 Dec 2024 10:27:23 -0600 Subject: [PATCH] Tools: add Plane autoland applet --- Tools/autotest/arduplane.py | 35 +++++++++++++++++++ .../applets/UniversalAutoLand.lua | 6 ++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Tools/autotest/arduplane.py b/Tools/autotest/arduplane.py index 7fabd6cd07816..d075b0a6cde9e 100644 --- a/Tools/autotest/arduplane.py +++ b/Tools/autotest/arduplane.py @@ -5326,6 +5326,40 @@ def AerobaticsScripting(self): else: raise NotAchievedException("Missing trick %s" % t) + def UniversalAutoLandScript(self): + '''Test UniversalAutoLandScript''' + applet_script = "UniversalAutoLand.lua" + self.customise_SITL_commandline(["--home", "-35.362938,149.165085,585,173"]) + + self.install_applet_script_context(applet_script) + self.context_collect('STATUSTEXT') + self.set_parameters({ + "SCR_ENABLE" : 1, + "SCR_VM_I_COUNT" : 1000000, + "RTL_AUTOLAND" : 2 + }) + self.reboot_sitl() + self.wait_text("Loaded UniversalAutoLand.lua", check_context=True) + self.set_parameters({ + "AUTOLAND_ENABLE" : 1, + "AUTOLAND_WP_ALT" : 55, + "AUTOLAND_WP_DIST" : 400 + }) + self.scripting_restart() + self.wait_text("Scripting: restarted", check_context=True) + + self.wait_ready_to_arm() + self.arm_vehicle() + self.change_mode("AUTO") + self.wait_text("Captured initial takeoff direction", check_context=True) + + self.wait_disarmed(120) + self.progress("Check the landed heading matches takeoff") + self.wait_heading(173, accuracy=5, timeout=1) + loc = mavutil.location(-35.362938, 149.165085, 585, 173) + if self.get_distance(loc, self.mav.location()) > 35: + raise NotAchievedException("Did not land close to home") + def SDCardWPTest(self): '''test BRD_SD_MISSION support''' spiral_script = "mission_spiral.lua" @@ -6457,6 +6491,7 @@ def tests1a(self): self.Soaring, self.Terrain, self.TerrainMission, + self.UniversalAutoLandScript, ]) return ret diff --git a/libraries/AP_Scripting/applets/UniversalAutoLand.lua b/libraries/AP_Scripting/applets/UniversalAutoLand.lua index 3b6839f996f9a..282a644e5df05 100644 --- a/libraries/AP_Scripting/applets/UniversalAutoLand.lua +++ b/libraries/AP_Scripting/applets/UniversalAutoLand.lua @@ -13,7 +13,7 @@ function bind_add_param(name, idx, default_value) end --[[ - // @Param: ENABLE + // @Param: AUTOLAND_ENABLE // @DisplayName: AUTOLAND ENABLE // @Description: enable AUTOLAND script action // @Values: 0:Disabled,1:Enabled @@ -23,7 +23,7 @@ local AULND_ENABLE = bind_add_param('ENABLE', 1, 1) local enable = AULND_ENABLE:get() --[[ - // @Param: WP_ALT + // @Param: AUTOLAND_WP_ALT // @DisplayName: Final approach waypoint alt // @Description: Altitude of final approach waypoint created by script // @Range: 1 100 @@ -33,7 +33,7 @@ local enable = AULND_ENABLE:get() local AULND_ALT = bind_add_param('WP_ALT', 2, 0) local final_wp_alt = AULND_ALT:get() --[[ - // @Param: WP_DIST + // @Param: AUTOLAND_WP_DIST // @DisplayName: Final approach waypoint distance // @Description: Distance from landng point (HOME) to final approach waypoint created by script in the opposite direction of initial takeoff // @Range: 0 1000