From 7dc6dee5a00a89904ba9a1003d8fc17b079dec86 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Mon, 6 Mar 2023 14:00:24 +0000 Subject: [PATCH] autotest: test Yaw D autotune --- Tools/autotest/arducopter.py | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index 5a9f3e4f92..5e30a0bb97 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -2325,6 +2325,45 @@ class AutoTestCopter(AutoTest): raise NotAchievedException("AUTOTUNE failed (%u seconds)" % (self.get_sim_time() - tstart)) + def AutoTuneYawD(self): + """Test autotune mode""" + + rlld = self.get_parameter("ATC_RAT_RLL_D") + rlli = self.get_parameter("ATC_RAT_RLL_I") + rllp = self.get_parameter("ATC_RAT_RLL_P") + self.set_parameter("ATC_RAT_RLL_SMAX", 1) + self.set_parameter("AUTOTUNE_AXES", 15) + self.takeoff(10) + + # hold position in loiter + self.change_mode('AUTOTUNE') + + tstart = self.get_sim_time() + sim_time_expected = 5000 + deadline = tstart + sim_time_expected + while self.get_sim_time_cached() < deadline: + now = self.get_sim_time_cached() + m = self.mav.recv_match(type='STATUSTEXT', + blocking=True, + timeout=1) + if m is None: + continue + self.progress("STATUSTEXT (%u<%u): %s" % (now, deadline, m.text)) + if "AutoTune: Success" in m.text: + self.progress("AUTOTUNE OK (%u seconds)" % (now - tstart)) + # near enough for now: + self.change_mode('LAND') + self.wait_landed_and_disarmed() + # check the original gains have been re-instated + if (rlld != self.get_parameter("ATC_RAT_RLL_D") or + rlli != self.get_parameter("ATC_RAT_RLL_I") or + rllp != self.get_parameter("ATC_RAT_RLL_P")): + raise NotAchievedException("AUTOTUNE gains still present") + return + + raise NotAchievedException("AUTOTUNE failed (%u seconds)" % + (self.get_sim_time() - tstart)) + def AutoTuneSwitch(self): """Test autotune on a switch with gains being saved""" @@ -9553,6 +9592,7 @@ class AutoTestCopter(AutoTest): self.AuxSwitchOptions, self.AuxFunctionsInMission, self.AutoTune, + self.AutoTuneYawD, self.NoRCOnBootPreArmFailure, ]) return ret