|
|
|
@ -456,7 +456,7 @@ void Plane::update_dynamic_notch()
@@ -456,7 +456,7 @@ void Plane::update_dynamic_notch()
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (ins.get_gyro_harmonic_notch_tracking_mode()) { |
|
|
|
|
case HarmonicNotchDynamicMode::UpdateThrottle: // throttle based tracking
|
|
|
|
|
case HarmonicNotchDynamicMode::UpdateThrottle: // throttle based tracking
|
|
|
|
|
// set the harmonic notch filter frequency approximately scaled on motor rpm implied by throttle
|
|
|
|
|
if (quadplane.available()) { |
|
|
|
|
ins.update_harmonic_notch_freq_hz(ref_freq * MAX(1.0f, sqrtf(quadplane.motors->get_throttle_out() / ref))); |
|
|
|
@ -474,13 +474,37 @@ void Plane::update_dynamic_notch()
@@ -474,13 +474,37 @@ void Plane::update_dynamic_notch()
|
|
|
|
|
break; |
|
|
|
|
#ifdef HAVE_AP_BLHELI_SUPPORT |
|
|
|
|
case HarmonicNotchDynamicMode::UpdateBLHeli: // BLHeli based tracking
|
|
|
|
|
ins.update_harmonic_notch_freq_hz(MAX(ref_freq, AP_BLHeli::get_singleton()->get_average_motor_frequency_hz() * ref)); |
|
|
|
|
// set the harmonic notch filter frequency scaled on measured frequency
|
|
|
|
|
if (ins.has_harmonic_option(HarmonicNotchFilterParams::Options::DynamicHarmonic)) { |
|
|
|
|
float notches[INS_MAX_NOTCHES]; |
|
|
|
|
const uint8_t num_notches = AP_BLHeli::get_singleton()->get_motor_frequencies_hz(INS_MAX_NOTCHES, notches); |
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < num_notches; i++) { |
|
|
|
|
notches[i] = MAX(ref_freq, notches[i]); |
|
|
|
|
} |
|
|
|
|
if (num_notches > 0) { |
|
|
|
|
ins.update_harmonic_notch_frequencies_hz(num_notches, notches); |
|
|
|
|
} else if (quadplane.available()) { // throttle fallback
|
|
|
|
|
ins.update_harmonic_notch_freq_hz(ref_freq * MAX(1.0f, sqrtf(quadplane.motors->get_throttle_out() / ref))); |
|
|
|
|
} else { |
|
|
|
|
ins.update_harmonic_notch_freq_hz(ref_freq); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ins.update_harmonic_notch_freq_hz(MAX(ref_freq, AP_BLHeli::get_singleton()->get_average_motor_frequency_hz() * ref)); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
#endif |
|
|
|
|
#if HAL_GYROFFT_ENABLED |
|
|
|
|
case HarmonicNotchDynamicMode::UpdateGyroFFT: // FFT based tracking
|
|
|
|
|
// set the harmonic notch filter frequency scaled on measured frequency
|
|
|
|
|
ins.update_harmonic_notch_freq_hz(gyro_fft.get_weighted_noise_center_freq_hz()); |
|
|
|
|
if (ins.has_harmonic_option(HarmonicNotchFilterParams::Options::DynamicHarmonic)) { |
|
|
|
|
float notches[INS_MAX_NOTCHES]; |
|
|
|
|
const uint8_t peaks = gyro_fft.get_weighted_noise_center_frequencies_hz(INS_MAX_NOTCHES, notches); |
|
|
|
|
|
|
|
|
|
ins.update_harmonic_notch_frequencies_hz(peaks, notches); |
|
|
|
|
} else { |
|
|
|
|
ins.update_harmonic_notch_freq_hz(gyro_fft.get_weighted_noise_center_freq_hz()); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
#endif |
|
|
|
|
case HarmonicNotchDynamicMode::Fixed: // static
|
|
|
|
|