Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Static Notches #28034

Merged
merged 3 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Tools/autotest/arducopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6011,6 +6011,7 @@ def ThrowMode(self):

def hover_and_check_matched_frequency_with_fft_and_psd(self, dblevel=-15, minhz=200, maxhz=300, peakhz=None,
reverse=None, takeoff=True, instance=0):
'''Takeoff and hover, checking the noise against the provided db level and returning psd'''
# find a motor peak
if takeoff:
self.takeoff(10, mode="ALT_HOLD")
Expand Down Expand Up @@ -6041,6 +6042,7 @@ def hover_and_check_matched_frequency_with_fft_and_psd(self, dblevel=-15, minhz=

def hover_and_check_matched_frequency_with_fft(self, dblevel=-15, minhz=200, maxhz=300, peakhz=None,
reverse=None, takeoff=True, instance=0):
'''Takeoff and hover, checking the noise against the provided db level and returning peak db'''
freq, hover_throttle, peakdb, psd = \
self.hover_and_check_matched_frequency_with_fft_and_psd(dblevel, minhz,
maxhz, peakhz, reverse, takeoff, instance)
Expand Down Expand Up @@ -6335,6 +6337,33 @@ def PIDNotches(self):

self.hover_and_check_matched_frequency_with_fft(dblevel=5, minhz=20, maxhz=350, reverse=True)

def StaticNotches(self):
"""Use static harmonic notch to control motor noise."""
self.progress("Flying with Static notches")
self.set_parameters({
"AHRS_EKF_TYPE": 10,
"INS_LOG_BAT_MASK": 3,
"INS_LOG_BAT_OPT": 4,
"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": 120, # yaw
"SIM_VIB_MOT_MULT": 0,
"SIM_GYR1_RND": 5,
"INS_HNTCH_ENABLE": 1,
"INS_HNTCH_FREQ": 120,
"INS_HNTCH_REF": 1.0,
"INS_HNTCH_HMNCS": 3, # first and second harmonic
"INS_HNTCH_ATT": 50,
"INS_HNTCH_BW": 40,
"INS_HNTCH_MODE": 0, # static notch
})
self.reboot_sitl()

self.hover_and_check_matched_frequency_with_fft(dblevel=-15, minhz=20, maxhz=350, reverse=True, instance=2)

def ThrottleGainBoost(self):
"""Use PD and Angle P boost for anti-gravity."""
# basic gyro sample rate test
Expand Down Expand Up @@ -11848,6 +11877,7 @@ def tests2b(self): # this block currently around 9.5mins here
self.PositionWhenGPSIsZero,
self.DynamicRpmNotches, # Do not add attempts to this - failure is sign of a bug
self.PIDNotches,
self.StaticNotches,
self.RefindGPS,
Test(self.GyroFFT, attempts=1, speedup=8),
Test(self.GyroFFTHarmonic, attempts=4, speedup=8),
Expand Down
2 changes: 2 additions & 0 deletions libraries/Filter/HarmonicNotchFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ void HarmonicNotchFilter<T>::init(float sample_freq_hz, HarmonicNotchFilterParam
NotchFilter<T>::calculate_A_and_Q(center_freq_hz, bandwidth_hz / _composite_notches, attenuation_dB, _A, _Q);

_initialised = true;
// ensure static notches are allocated and working
update(center_freq_hz);
andyp1per marked this conversation as resolved.
Show resolved Hide resolved
}

/*
Expand Down
Loading