From 49e77718ac921c840b901a6039c95534f37490e7 Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Thu, 11 Jul 2024 00:11:16 +0100 Subject: [PATCH] Tools: autotest: Copter: add battery unhealthy prearm and failsafe test --- Tools/autotest/arducopter.py | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index 6c058d762c..5201873463 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -1115,6 +1115,43 @@ class AutoTestCopter(vehicle_test_suite.TestSuite): self.progress("All Battery failsafe tests complete") + def BatteryMissing(self): + ''' Test battery health pre-arm and missing failsafe''' + self.context_push() + + # Should be good to arm with no changes + self.wait_ready_to_arm() + + # Make monitor unhealthy, this should result in unhealthy prearm + self.set_parameters({ + 'BATT_VOLT_PIN': -1, + }) + + self.drain_mav() + + # Battery should go unhealthy immediately + self.assert_prearm_failure("Battery 1 unhealthy", other_prearm_failures_fatal=False) + + # Return monitor to health + self.context_pop() + self.context_push() + + self.wait_ready_to_arm() + + # take off and then trigger in flight + self.takeoff(10, mode="LOITER") + self.set_parameters({ + 'BATT_VOLT_PIN': -1, + }) + + # Should trigger missing failsafe + self.wait_statustext("Battery 1 is missing") + + # Done, reset params and reboot to clear failsafe + self.land_and_disarm() + self.context_pop() + self.reboot_sitl() + def VibrationFailsafe(self): '''Test Vibration Failsafe''' self.context_push() @@ -10449,6 +10486,7 @@ class AutoTestCopter(vehicle_test_suite.TestSuite): '''return list of all tests''' ret = ([ self.BatteryFailsafe, + self.BatteryMissing, self.VibrationFailsafe, self.EK3AccelBias, self.StabilityPatch,