Flowchart

State vector

State

  • Attitude (quaternion)
  • Velocity (NED frame)
  • Position (NED frame)
  • IMU biases (3 for gyroscope, 3 for accelerometer)
  • Earth’s magnetic field vector (NED frame)
  • Magnetometer bias (hard/soft iron bias; body frame)
  • Wind velocity (North and East components for wind estimation)
  • Terrain altitude (height of terrain ie ground above a reference)

State error vector

state_error

True state vector

state_t

Noise vector

noise

Implementation details

Error state formulation

  • To improve stability
  • Instead of estimating full state errors directly, small error corrections to a nominal state are tracked

Prediction step

  • Uses IMU data only

Code implementation

1. predict_covariance

New symbolsMeaningVariable name
raw IMU specific force and angular-rate samplesaccel, gyro
estimated IMU biasesstate["accel_bias"], state["gyro_bias"]
, element-wise accel / gyro variancesaccel_var, gyro_var
Discrete-time state-transition Jacobian in the error-state space (how the error evolves from step to )A
Process-noise Jacobian (how the IMU noise influences the error dynamics during the step)G

Nominal state propagation

Error-state kinematics

Covariance propagation


2. compute_airspeed_innov_and_innov_var

Wind-compensated relative velocity

Predicted airspeed

Innovation

Jacobian

Innovation variance

New symbolVariable name
airspeed
R
state["wind_vel"][0], [1]

3. compute_airspeed_h_and_k

Kva=PHvaT Sva−1,Hva as above.

(No new symbols.)


4. compute_wind_init_and_cov_from_airspeed

The covariance is found with first-order error propagation
, where is the Jacobian of the above mapping and the diagonal matrix of the supplied variances.

New / mapped symbols

symbolpython variable
v_local[0], v_local[1] (aircraft velocity in local-NED)
heading
explicit symbolic sideslip
constructed from v_var, heading_var, sideslip_var, airspeed_var

5. compute_wind_init_and_cov_from_wind_speed_and_direction

with
.

symbolpython variable
wind_speed
wind_direction
, wind_speed_var, wind_direction_var

6. predict_sideslip & compute_sideslip_*

symbolpython variable
R

7. predict_vel_body & body-velocity helpers

For each axis :

symbolpython variable
components of an external body-frame velocity sensor (if present) or zeros when only is requested
entries of vector R (or scalar for *_y/z variants)

8. predict_mag_body & magnetometer helpers

Each component innovation , jacobian , variance (and Kalman gain if required) follow the same pattern as above.

symbolpython variable
state["mag_B"]
state["mag_I"]
R

9. compute_yaw_innov_var_and_h

symbolpython variable
R

10. compute_mag_declination_pred_innov_var_and_h


11. predict_hagl, optical-flow & HAGL helpers

Optical-flow LOS-rate prediction (sensor frame):

Each axis uses the usual Kalman innovation/variance formulas.


12. compute_gnss_yaw_pred_innov_var_and_h

symbolpython variable
antenna_yaw_offset
R

13. predict_drag & drag helpers


14. predict_gravity_direction & gravity helpers

Each component innovation and variance again follows the generic pattern.


How to read these blocks

  1. Every measurement helper shares the same EKF algebra:

    • predicted measurement

    • innovation

    • Jacobian , innovation variance , gain .

  2. All quaternion updates use the small-angle approximation
    ,
    matching the theta component of state_error.

  3. All Jacobians are built exactly as in the script via SymForce, but their analytical expressions are those shown above.