autotest: test Yaw D autotune

This commit is contained in:
Andy Piper 2023-03-06 14:00:24 +00:00 committed by Andrew Tridgell
parent 0f6d62c196
commit 7dc6dee5a0
1 changed files with 40 additions and 0 deletions

View File

@ -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