From 946c891e14af3b6e764325d82bb26b0557a78c01 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Thu, 2 May 2024 21:37:07 +0100 Subject: [PATCH] autotest: improve reliability of MotorVibration test --- Tools/autotest/arducopter.py | 7 ++++--- Tools/autotest/vehicle_test_suite.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index a04026b39b..a74e5a3c1f 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -3178,9 +3178,10 @@ class AutoTestCopter(vehicle_test_suite.TestSuite): psd = self.mavfft_fttd(1, 0, tstart * 1.0e6, tend * 1.0e6) # ignore the first 20Hz and look for a peak at -15dB or more - ignore_bins = 20 + # it should be at about 190Hz, each bin is 1000/1024Hz wide + ignore_bins = int(100 * 1.024) # start at 100Hz to be safe freq = psd["F"][numpy.argmax(psd["X"][ignore_bins:]) + ignore_bins] - if numpy.amax(psd["X"][ignore_bins:]) < -15 or freq < 180 or freq > 300: + if numpy.amax(psd["X"][ignore_bins:]) < -15 or freq < 100 or freq > 300: raise NotAchievedException( "Did not detect a motor peak, found %f at %f dB" % (freq, numpy.amax(psd["X"][ignore_bins:]))) @@ -11308,7 +11309,7 @@ class AutoTestCopter(vehicle_test_suite.TestSuite): self.MotorVibration, Test(self.DynamicNotches, attempts=4), self.PositionWhenGPSIsZero, - self.DynamicRpmNotches, + self.DynamicRpmNotches, # Do not add attempts to this - failure is sign of a bug self.PIDNotches, self.RefindGPS, Test(self.GyroFFT, attempts=1, speedup=8), diff --git a/Tools/autotest/vehicle_test_suite.py b/Tools/autotest/vehicle_test_suite.py index dc4b7c1d5a..c72f984497 100644 --- a/Tools/autotest/vehicle_test_suite.py +++ b/Tools/autotest/vehicle_test_suite.py @@ -14208,6 +14208,8 @@ SERIAL5_BAUD 128 sample_rate = 0 counts = 0 window = numpy.hanning(fft_len) + # The returned float array f contains the frequency bin centers in cycles per unit of the + # sample spacing (with zero at the start). freqmap = numpy.fft.rfftfreq(fft_len, 1.0 / messages[0].sample_rate_hz) # calculate NEBW constant