autotest: add test for FFT continuous averaging

This commit is contained in:
Andy Piper 2022-05-05 20:39:53 +01:00 committed by Peter Hall
parent 044aaf3004
commit f244866329

View File

@ -5290,13 +5290,13 @@ class AutoTestCopter(AutoTest):
return freq return freq
def fly_gyro_fft_harmonic(self): def test_gyro_fft_harmonic(self, averaging):
"""Use dynamic harmonic notch to control motor noise with harmonic matching of the first harmonic.""" """Use dynamic harmonic notch to control motor noise with harmonic matching of the first harmonic."""
# basic gyro sample rate test # basic gyro sample rate test
self.progress("Flying with gyro FFT harmonic - Gyro sample rate") self.progress("Flying with gyro FFT harmonic - Gyro sample rate")
self.context_push() self.context_push()
ex = None ex = None
# we are dealing with probabalistic scenarios involving threads, have two bites at the cherry # we are dealing with probabalistic scenarios involving threads
try: try:
self.start_subtest("Hover to calculate approximate hover frequency") self.start_subtest("Hover to calculate approximate hover frequency")
# magic tridge EKF type that dramatically speeds up the test # magic tridge EKF type that dramatically speeds up the test
@ -5315,6 +5315,7 @@ class AutoTestCopter(AutoTest):
"FFT_THR_REF": self.get_parameter("MOT_THST_HOVER"), "FFT_THR_REF": self.get_parameter("MOT_THST_HOVER"),
"SIM_GYR1_RND": 20, # enable a noisy gyro "SIM_GYR1_RND": 20, # enable a noisy gyro
}) })
# motor peak enabling FFT will also enable the arming # motor peak enabling FFT will also enable the arming
# check, self-testing the functionality # check, self-testing the functionality
self.set_parameters({ self.set_parameters({
@ -5323,6 +5324,8 @@ class AutoTestCopter(AutoTest):
"FFT_MAXHZ": 450, "FFT_MAXHZ": 450,
"FFT_SNR_REF": 10, "FFT_SNR_REF": 10,
}) })
if averaging:
self.set_parameter("FFT_NUM_FRAMES", 8)
# Step 1: inject actual motor noise and use the FFT to track it # Step 1: inject actual motor noise and use the FFT to track it
self.set_parameters({ self.set_parameters({
@ -5437,6 +5440,15 @@ class AutoTestCopter(AutoTest):
if ex is not None: if ex is not None:
raise ex raise ex
def fly_gyro_fft_harmonic(self):
"""Use dynamic harmonic notch to control motor noise with harmonic matching of the first harmonic."""
self.test_gyro_fft_harmonic(False)
def fly_gyro_fft_continuous_averaging(self):
"""Use dynamic harmonic notch with FFT averaging to control motor noise
with harmonic matching of the first harmonic."""
self.test_gyro_fft_harmonic(True)
def fly_gyro_fft(self): def fly_gyro_fft(self):
"""Use dynamic harmonic notch to control motor noise.""" """Use dynamic harmonic notch to control motor noise."""
# basic gyro sample rate test # basic gyro sample rate test
@ -9083,6 +9095,11 @@ class AutoTestCopter(AutoTest):
self.fly_gyro_fft_average, self.fly_gyro_fft_average,
attempts=1), attempts=1),
Test("GyroFFTContinuousAveraging",
"Fly Gyro FFT Continuous averaging",
self.fly_gyro_fft_continuous_averaging,
attempts=8),
Test("CompassReordering", Test("CompassReordering",
"Test Compass reordering when priorities are changed", "Test Compass reordering when priorities are changed",
self.test_mag_reordering), # 40sec? self.test_mag_reordering), # 40sec?