mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 19:07:45 +08:00
sensors/vehicle_angular_velocity: small FFT notch update simplification
This commit is contained in:
@@ -543,18 +543,17 @@ void VehicleAngularVelocity::UpdateDynamicNotchFFT(bool force)
|
|||||||
const float peak_freq = peak_frequencies[axis][peak];
|
const float peak_freq = peak_frequencies[axis][peak];
|
||||||
|
|
||||||
if (PX4_ISFINITE(peak_freq) && (peak_freq > peak_freq_min) && (peak_freq < peak_freq_max)) {
|
if (PX4_ISFINITE(peak_freq) && (peak_freq > peak_freq_min) && (peak_freq < peak_freq_max)) {
|
||||||
// force reset if the notch frequency jumps significantly
|
|
||||||
if (fabsf(nf.getNotchFreq() - peak_freq) > bandwidth) {
|
const float notch_freq_diff = fabsf(nf.getNotchFreq() - peak_freq);
|
||||||
reset = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// update filter parameters if frequency changed or forced
|
// update filter parameters if frequency changed or forced
|
||||||
if (force || (fabsf(nf.getNotchFreq() - peak_freq) > FLT_EPSILON)) {
|
if (force || reset || (notch_freq_diff > 0.1f)) {
|
||||||
nf.setParameters(_filter_sample_rate_hz, peak_freq, bandwidth);
|
nf.setParameters(_filter_sample_rate_hz, peak_freq, bandwidth);
|
||||||
perf_count(_dynamic_notch_filter_fft_update_perf);
|
perf_count(_dynamic_notch_filter_fft_update_perf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force || reset) {
|
// force reset if the notch frequency jumps significantly
|
||||||
|
if (force || reset || (notch_freq_diff > bandwidth)) {
|
||||||
const Vector3f reset_angular_velocity{GetResetAngularVelocity()};
|
const Vector3f reset_angular_velocity{GetResetAngularVelocity()};
|
||||||
nf.reset(reset_angular_velocity(axis));
|
nf.reset(reset_angular_velocity(axis));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user