Skip to content

Commit

Permalink
autotest: add PID notches test
Browse files Browse the repository at this point in the history
  • Loading branch information
andyp1per committed Sep 17, 2023
1 parent 7c6f34b commit 9a7f960
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Tools/autotest/helicopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,46 @@ def TurbineStart(self, timeout=200):
self.set_rc(8, 1000)
self.disarm_vehicle()

def PIDNotches(self):
"""Use dynamic harmonic notch to control motor noise."""
self.progress("Flying with PID notches")
self.context_push()

ex = None
try:
self.set_parameters({
"AHRS_EKF_TYPE": 10,
"INS_LOG_BAT_MASK": 3,
"INS_LOG_BAT_OPT": 0,
"INS_GYRO_FILTER": 100, # set the gyro filter high so we can observe behaviour
"LOG_BITMASK": 65535,
"LOG_DISARMED": 0,
"SIM_VIB_FREQ_X": 120, # roll
"SIM_VIB_FREQ_Y": 120, # pitch
"SIM_VIB_FREQ_Z": 180, # yaw
"ATC_RAT_RLL_NEF": 120,
"ATC_RAT_RLL_NBW": 50,
"ATC_RAT_PIT_NEF": 120,
"ATC_RAT_PIT_NBW": 50,
"ATC_RAT_YAW_NEF": 180,
"ATC_RAT_YAW_NBW": 50,
"SIM_GYR1_RND": 5,
})
self.reboot_sitl()

self.takeoff(10, mode="ALT_HOLD")

freq, hover_throttle, peakdb1 = self.hover_and_check_matched_frequency_with_fft(5, 20, 350, reverse=True)

except Exception as e:
self.print_exception_caught(e)
ex = e

self.context_pop()

if ex is not None:
raise ex

def tests(self):
'''return list of all tests'''
ret = AutoTest.tests(self)
Expand All @@ -823,6 +863,7 @@ def tests(self):
self.AirspeedDrivers,
self.TurbineStart,
self.NastyMission,
self.PIDNotches,
])
return ret

Expand Down

0 comments on commit 9a7f960

Please sign in to comment.