MAVLINKHUD

Overview

The FILT parameter group configures frequency-domain filters used to clean raw sensor data (IMU, Baro, Airspeed) before it is used by the control loops.

All digital sensors contain noise. Filtering removes high-frequency vibrations and "jitter," but introduces a small amount of "phase lag" (delay). Finding the right balance is the key to a stable vehicle.

Key Concepts

1. Low-Pass Filters (FILT_HZ)

A low-pass filter allows slow movements (pilot commands) to pass while blocking fast movements (motor vibrations).

  • FILT_HZ: The cutoff frequency.
    • Higher Hz: Less delay, but more noise.
    • Lower Hz: Cleaner signal, but the vehicle might feel "mushy" or oscillate due to the delay in control response.

2. Notch Filters (FILT1_NOTCH_...)

A notch filter targets a specific narrow frequency range (e.g., exactly 120Hz) to erase a known vibration without affecting other frequencies.

Parameter Breakdown

  • FILT_HZ: General filter cutoff frequency.
  • FILT1_NOTCH_FREQ: Center frequency of the notch.
  • FILT1_NOTCH_Q: Sharpness (width) of the notch.

Integration Guide

  • Default: Start with default values.
  • Vibrations: If your drone has high vibrations (check logs), you may need to lower the FILT_HZ for the D-term or enable a Harmonic Notch.

Developer Notes

  • Library: libraries/AP_Filter.
  • Context: These are often used as low-level helpers within AP_InertialSensor and AC_AttitudeControl.

FILT1_NOTCH_ATT

Default 0.1
Range 0 1.0

Notch Filter Attenuation (FILT1_NOTCH_ATT)

Description

FILT1_NOTCH_ATT defines how much of the noise is removed. A value of 0.1 reduces the signal at that frequency to 10% of its original strength.

FILT1_NOTCH_FREQ

Hz
Default 0
Range 10 500

Notch Filter Center Frequency (FILT1_NOTCH_FREQ)

Description

FILT1_NOTCH_FREQ defines the "Target" of a specialized electrical filter used to clean up noisy sensor data.

A Notch Filter removes one specific frequency while leaving others untouched. This is most commonly used to eliminate the vibration frequency of a drone's motors from the accelerometer or gyroscope data, allowing for much sharper and more stable flight control.

Tuning & Behavior

  • Default: 0 (Disabled).
  • Usage: Find your frame's peak vibration frequency using the FFT diagnostic tool or by analyzing logs. Enter that frequency here.
  • Effect: Reduces mechanical "noise" that would otherwise confuse the PID controller.
  • Integration: Must be used with FILT1_NOTCH_Q to define the width of the filter.

FILT1_NOTCH_Q

Default 1.0
Range 0.1 5.0

Notch Filter Quality Factor (FILT1_NOTCH_Q)

Description

FILT1_NOTCH_Q determines how narrow the "Notch" is.

  • Higher Q (e.g. 2.0): Narrow notch. Removes a very specific frequency without affecting nearby data.
  • Lower Q (e.g. 0.5): Wide notch. Removes a broader range of frequencies around the center.

FILT_HZ

Hz
Default 5
Range 1 100

FlowHold Filter Frequency (FILT_HZ)

Description

This parameter sets the cutoff frequency for the low-pass filter applied to Optical Flow sensor data when using FlowHold mode. Optical flow sensors (which measure the "movement" of the ground beneath the drone) can be noisy due to surface texture, lighting, or vibration.

A lower frequency makes the drone's position hold feel "softer" and more resistant to noise, but it adds latency (delay) to the control loop. A higher frequency makes the drone react more instantly to movement but can cause "jitter" if the sensor data is noisy.

The Mathematics

The filter is a standard first-order Low Pass Filter (LPF). The relationship between the cutoff frequency ($f\_c$) and the filter's time constant ($\tau$) is:

$$ \tau = \frac{1}{2 \pi f\_c} $$

The smoothing coefficient ($\alpha$) used in each update step is:

$$ \alpha = \frac{dt}{dt + \tau} $$

Where $dt$ is the loop time (typically 0.0025s for a 400Hz control loop). At the default of 5Hz, the time constant is approximately 0.031s, providing significant smoothing for raw flow data.

The Engineer's View

In AC_PI_2D.cpp, the parameter _filt_hz is used to calculate the filter coefficient.

  1. The code enforces a minimum frequency of 0.01Hz to prevent division-by-zero errors.
  2. In the update() loop, the raw flow error is passed through this filter before the Proportional (P) and Integral (I) gains are applied.
  3. This ensures that high-frequency noise from the sensor does not "kick" the motors, which would cause audible chirping and wasted battery energy.

Tuning & Behavior

  • Default Value: 5 Hz.
  • Range: 1 to 100 Hz.
  • Effect of Increasing: The vehicle will respond more aggressively to small drifts. Use this if the drone feels "lazy" in FlowHold but you have a very clean, high-quality sensor (e.g., HereFlow).
  • Effect of Decreasing: The vehicle will feel more stable but may drift further before correcting. Use this if you see the drone "shaking" or "twitching" in a hover.
  • Dependencies: Primarily used when FLT_MODE is set to FlowHold.