From 7249265207313845c8cc7d427b3422f592fce8d6 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Fri, 13 Sep 2024 21:55:20 +0900 Subject: [PATCH] Tools: add copter pos offset test --- Tools/autotest/arducopter.py | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index 8a3d11b6f1ef77..b95c4a582da2d7 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -10766,6 +10766,58 @@ def ScriptMountPOI(self): self.context_pop() self.reboot_sitl() + def ScriptCopterPosOffsets(self): + '''test the copter-posoffset.lua example script''' + self.context_push() + + # enable scripting and arming/takingoff in Auto mode + self.set_parameters({ + "SCR_ENABLE": 1, + "AUTO_OPTIONS": 3, + "RC12_OPTION": 300 + }) + self.reboot_sitl() + + # install copter-posoffset script + self.install_example_script_context('copter-posoffset.lua') + self.reboot_sitl() + + # create simple mission with a single takeoff command + self.upload_simple_relhome_mission([ + (mavutil.mavlink.MAV_CMD_NAV_TAKEOFF, 0, 0, 20) + ]) + + # switch to loiter to wait for position estimate (aka GPS lock) + self.change_mode('LOITER') + self.wait_ready_to_arm() + + # arm and takeoff in Auto mode + self.change_mode('AUTO') + self.arm_vehicle() + + # wait for vehicle to climb to at least 10m + self.wait_altitude(8, 12, relative=True) + + # add position offset to East and confirm vehicle moves + self.set_parameter("PSC_OFS_POS_E", 20) + self.set_rc(12, 2000) + self.wait_distance(18) + + # remove position offset and wait for vehicle to return home + self.set_parameter("PSC_OFS_POS_E", 0) + self.wait_distance_to_home(distance_min=0, distance_max=4, timeout=20) + + # add velocity offset and confirm vehicle moves + self.set_parameter("PSC_OFS_VEL_N", 5) + self.wait_groundspeed(4.8, 5.2, minimum_duration=5, timeout=20) + + # remove velocity offset and switch to RTL + self.set_parameter("PSC_OFS_VEL_N", 0) + self.set_rc(12, 1000) + self.do_RTL() + self.context_pop() + self.reboot_sitl() + def AHRSTrimLand(self): '''test land detector with significant AHRS trim''' self.context_push() @@ -12133,6 +12185,7 @@ def tests2b(self): # this block currently around 9.5mins here self.TerrainDBPreArm, self.ThrottleGainBoost, self.ScriptMountPOI, + self.ScriptCopterPosOffsets, self.MountSolo, self.FlyMissionTwice, self.FlyMissionTwiceWithReset,