Flight Controller / Sensors

FC8 — Gyroscopes and Accelerometers

Sensor Fusion Roles and Mathematical Error Models
Contents

    Last time, we discussed countermeasures for IMU vibrations. In this article, which is FC8, we will delve into the roles of the gyroscope and accelerometer that make up the IMU from the perspective of sensor fusion. The two sensors have different error characteristics, and their complementary relationship forms the basis of attitude estimation using EKF.

    Complementary Roles of Gyroscope and Accelerometer

    Although both the gyroscope and accelerometer are used for attitude estimation, they excel under opposite conditions.

    Because the gyroscope directly measures angular velocity, it can track attitude changes with high precision over short periods. However, due to bias drift, integrating angular velocity to obtain an angle causes errors to accumulate over time. It is a sensor that is "accurate in the short term, but drifts in the long term."

    Since the accelerometer accurately indicates the direction of gravity in a static state, it can estimate absolute roll and pitch angles (tilt relative to the gravity vector) stably over the long term. However, when the aircraft undergoes accelerated motion, gravity and aircraft acceleration overlap, disrupting attitude estimation. It is a sensor that is "stable in the long term, but disrupted by acceleration in the short term."

    Combining these complementary characteristics is the core of attitude estimation. Tracking high-frequency attitude changes with the gyroscope while correcting low-frequency bias drift with the accelerometer—this is the fundamental concept of complementary filters and EKF.

    Gyroscope Error Model

    The gyroscope output ω_meas is expressed relative to the ideal value ω_true by the following model:

    ω_meas = ω_true + b_g + n_g

    b_g is the gyro bias, and n_g is the gyro noise.

    Gyro bias b_g is further divided into two components. The steady-state bias (fixed offset) can be measured at power-on and removed through calibration. ArduPilot averages the gyro output for several seconds while the aircraft is stationary at startup and subtracts this average value as the bias estimate.

    Bias instability (random walk component) is a component that changes randomly over time and cannot be removed by initial calibration. ArduPilot's approach is to include gyro bias in the EKF state variables and estimate and correct it in real-time during flight. The EKF uses accelerometer and GNSS information to estimate the bias.

    Gyro noise n_g is a white noise component characterized by the ARW (Angle Random Walk) discussed previously. A gyro with an ARW of 0.1 deg/√hr means that the RMS of the angle error after one hour will be 0.1 degrees.

    Temperature dependence is the largest factor in gyro bias fluctuation. A bias value calibrated at 20°C on the ground will differ significantly in a 0°C environment at an altitude of 1000m. The ICM-42688-P has built-in TC (temperature coefficient) correction, which, when combined with ArduPilot's temperature calibration function, handles temperature changes in the flight environment.

    Accelerometer Error Model

    The accelerometer output a_meas is:

    a_meas = a_true + b_a + n_a

    b_a is the accelerometer bias, and n_a is the accelerometer noise.

    Like gyro bias, accelerometer bias b_a has steady-state and random walk components. An important difference is the nature of the impact that accelerometer bias has on attitude estimation. While gyro bias causes angle errors to accumulate through integration, accelerometer bias directly introduces an offset into the estimation of the gravity vector direction.

    Accelerometer scale factor errors can be corrected through 6-axis calibration (6-point calibration). By placing the aircraft stationary with each of its six sides facing down, the scale factor and bias are estimated using the least-squares method so that gravity (1g) is measured accurately in each direction. ArduPilot's accel calibration function implements this.

    Accelerometer errors due to vibration were explained in the previous section. High-amplitude vibration causes signal saturation, and the averaged value of the saturated waveform shifts in the positive direction (clipping asymmetry). This apparent bias causes errors in the EKF's altitude estimation.

    Complementary Filter—Preliminary Knowledge for an Intuitive Understanding of EKF

    Before diving into EKF, it is helpful to understand the more intuitive complementary filter.

    A complementary filter simply combines the gyroscope and accelerometer. It uses weighting that trusts the gyroscope integration in the short term and the accelerometer's gravity direction estimation in the long term.

    The estimated attitude angle θ is:

    θ_est = α × (θ_est + ω × dt) + (1 - α) × θ_accel

    When α is close to 0, the accelerometer is prioritized; when close to 1, the gyroscope is prioritized. α is generally set between 0.98 and 0.995, and is expressed by the time constant τ = α × dt / (1 - α).

    While the complementary filter is simple and computationally light, it has limitations in fusing multiple sensors, handling non-linear systems, and statistically managing sensor noise. The EKF (Extended Kalman Filter) solves all of these issues.

    Handling of Each Sensor in EKF

    ArduPilot's EKF3 uses the gyroscope for state transition and the accelerometer, GNSS, barometer, and compass for observation updates.

    In state transition, the gyroscope output is used to propagate the previous step's attitude estimate to the current step:

    q_pred = q_prev ⊗ Δq(ω_meas - b_g, dt)

    Here, q is the attitude in quaternion representation, ⊗ is the quaternion product, and b_g is the gyro bias estimated by the EKF. The gyro noise covariance Q_gyro is input into the EKF's process noise matrix.

    In observation updates, the accelerometer is used as the direction of the gravity vector. The EKF corrects the attitude and gyro bias so that the difference (innovation) between the gravity direction predicted from the estimated attitude and the actual accelerometer output becomes small.

    Let's organize the correspondence between ArduPilot EKF parameters and sensor models. INS_GYRW_P (gyro white noise) is the standard deviation of n_g, set from the noise density in the IMU datasheet. EK3_GYRO_P_NSE (gyro process noise) is the random walk speed of b_g, set from the bias instability index value. EK3_ACC_P_NSE (accelerometer process noise) is the random walk speed of b_a.

    In principle, these parameters are derived from the IMU datasheet, but in actual flight environments (vibration, temperature), they may deviate from theoretical values, so they are adjusted while monitoring ArduPilot logs (EKF Innovation).

    Importance of Quaternion Representation

    There are three ways to represent attitude: Euler angles (roll, pitch, yaw), rotation matrices, and quaternions. The reason ArduPilot's EKF uses quaternions is to avoid the gimbal lock problem.

    When the pitch angle reaches ±90 degrees, one degree of freedom is lost in Euler angle representation, making the attitude representation indeterminate (gimbal lock). Quaternions (4 elements) do not have this problem and are numerically stable.

    However, quaternions have a constraint that the norm must be maintained at 1, and measures must be taken to maintain this constraint during EKF covariance propagation. ArduPilot's EKF3 uses a method called Error State EKF to make the quaternion norm constraint easier to handle.

    Linking Sensor Selection with EKF Parameters

    Changing sensors may require readjustment of EKF parameters. If you switch from an ICM-42688-P to a BMI088, the optimal value for EK3_GYRO_P_NSE will change because the specifications for gyro ARW and bias instability differ.

    While ArduPilot contains sensor-specific default parameters in its source code, optimization for each flight environment must be performed by the user. If the EKF Innovation in the logs shows large values for a specific sensor's innovation term, it is a signal to review that sensor's noise parameters.

    Summary

    The complementary characteristics—gyros having excellent short-term accuracy but suffering from drift, and accelerometers having long-term stability but being susceptible to vehicle acceleration—form the basis of attitude estimation via EKF. Accurately understanding error models (bias, random walk, noise) from datasheets and reflecting them in EKF process noise parameters is the key to high-precision attitude estimation. In the next installment, FC9, we will explain the implementation of the compass (magnetic sensor), including design considerations for mounting position and calibration.

    Explore Our Technologies

    KURAGE GCS

    Browser-Based Ground Control System

    KURAGE Vision

    AI Vision & Security Platform

    KURAGE FC

    Custom STM32H743 Flight Controller

    KURAGE Mission Computer

    Autonomy Engine for UAVs and Robotics