Skip to main content

Module attitude

Module attitude 

Source
Expand description

Attitude quaternion kinematics.

The attitude is a unit Hamilton quaternion q that rotates body-frame components into launch-frame (ENU) components, v_L = q ⊗ v_B ⊗ q* (glam’s DQuat::mul_vec3); see docs/physics/frames.md. With ω_B the body’s angular velocity relative to the launch frame, resolved in the body frame, the kinematic equation is

q̇ = ½ q ⊗ (0, ω_B)

(J. Solà, Quaternion kinematics for the error-state Kalman filter, arXiv:1711.02508v1, 2017, eq. 200 with the local angular rate ω_L; the same Hamilton convention and local-to-global mapping, eq. 206.)

A general-purpose integrator applied to q̇ does not preserve |q| = 1, so the flight engine projects back onto the unit sphere after every accepted step (renormalize). For a rate that is constant over the step, step_constant_rate is exact up to rounding: q(t + Δt) = q(t) ⊗ exp(½ ω_B Δt) (Solà eq. 215, zeroth-order integration).

Functions§

quaternion_derivative
The time derivative q̇ = ½ q ⊗ (0, ω_B) of the attitude quaternion, as a (non-unit) quaternion, for a body angular velocity omega_body_rad_s resolved in the body frame.
renormalize
Projects q back onto the unit sphere after an integration step.
step_constant_rate
Advances the attitude by dt_s under a body rate that is constant over the step: q ⊗ exp(½ ω_B Δt), then renormalized.