From 8927b2827362f6f316ab76cea302ef5e19d009e4 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 19 Jun 2024 13:34:37 +1000 Subject: [PATCH] Tools: add Copter flight option for requiring position to arm --- Tools/autotest/arducopter.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index f6f8e7a73b9cf..16e1bdfc1195c 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -11535,6 +11535,39 @@ def GripperReleaseOnThrustLoss(self): self.do_RTL() self.reboot_sitl() + def assert_home_position_not_set(self): + try: + self.poll_home_position() + except NotAchievedException: + return + + # if home.lng != 0: etc + + raise NotAchievedException("Home is set when it shouldn't be") + + def REQUIRE_POSITION_FOR_ARMING(self): + '''check FlightOption::REQUIRE_POSITION_FOR_ARMING works''' + self.context_push() + self.set_parameters({ + "SIM_GPS_NUMSATS": 3, # EKF does not like < 6 + }) + self.reboot_sitl() + self.change_mode('STABILIZE') + self.wait_prearm_sys_status_healthy() + self.assert_home_position_not_set() + self.arm_vehicle() + self.disarm_vehicle() + self.change_mode('LOITER') + self.assert_prearm_failure("waiting for home", other_prearm_failures_fatal=False) + + self.change_mode('STABILIZE') + self.set_parameters({ + "FLIGHT_OPTIONS": 8, + }) + self.assert_prearm_failure("Need Position Estimate", other_prearm_failures_fatal=False) + self.context_pop() + self.reboot_sitl() + def tests2b(self): # this block currently around 9.5mins here '''return list of all tests''' ret = ([ @@ -11626,6 +11659,7 @@ def tests2b(self): # this block currently around 9.5mins here self.GuidedWeatherVane, self.Clamp, self.GripperReleaseOnThrustLoss, + self.REQUIRE_POSITION_FOR_ARMING, ]) return ret