Numerical Quaternion Propagation and IMU Attitude State Integration
A gyroscope does not directly measure attitude. It measures angular motion. An inertial
navigation or attitude system must integrate that angular motion over time to update an
orientation state.
Quaternions are particularly well suited to this task because a unit quaternion can be updated by
a finite incremental rotation without introducing an Euler Angle singularity.
This article develops numerical propagation for the PhysicsLibrary passive attitude
quaternion
which maps coordinates from an inertial or reference frame I into a body frame B.
For body resolved angular velocity,
Over one sample interval, the exact constant rate update is
where
Thus the numerical implementation must preserve three convention facts:
- the body frame increment has a negative quaternion vector part;
- the body resolved increment multiplies on the left;
- the propagated quaternion maps reference coordinates into body coordinates.
1 Convention declaration
PhysicsLibrary uses Hamilton multiplication,
with reversed products changing sign.
Quaternion components are displayed scalar first:
The passive vector transformation is
For a positive frame rotation through angle 𝜃 about unit axis u,
The corresponding DCM satisfies
2 From gyroscope measurement to corrected angular rate
A practical body mounted gyroscope measurement can be modeled as
where
is gyroscope bias and
represents measurement noise.
Given a current bias estimate bg, form
For a simple zero order hold over sample interval Δt, the corresponding body resolved delta angle
is
If the IMU itself supplies a delta angle measurement, that integrated quantity should normally be
used directly after the appropriate bias correction and manufacturer specified compensation rather
than unnecessarily converting it to a rate and integrating it again.
3 Exact exponential increment
Let
If
define the unit increment axis
The exact passive body increment is
Equivalently,
In scalar first array notation,
The limiting value at Δ𝜃 = 0 is the identity quaternion.
4 Why body increments left multiply
During sample k, the old attitude maps
The measured body increment maps
The complete passive frame chain is therefore
PhysicsLibrary quaternion frame composition gives
Thus
The side of multiplication is a consequence of the declared frame map, not a change to Hamilton
multiplication.
5 Propagation flow
The following diagram summarizes the passive IMU attitude state propagation chain.
Figure. A body mounted IMU supplies angular motion and specific force. Gyroscope bias is
removed, a passive incremental quaternion is formed, and the increment left multiplies the inertial
to body attitude quaternion. The updated or appropriately time centered attitude is then used to
transform body specific force into the navigation or inertial frame. A multiplicative estimator may
carry a three component local error state while the nominal orientation remains a full unit
quaternion.
6 Small angle increment
For sufficiently small Δ𝜃,
and
Therefore
The corresponding first order update is
This is useful for analysis and for sufficiently small sample increments, but the exact
trigonometric increment is inexpensive and generally preferable when the delta angle is already
available.
7 Forward Euler integration
Starting from
a forward Euler step is
If
then
Thus forward Euler is equivalent to using the first order incremental quaternion without
normalization.
8 Why forward Euler leaves unit norm
The exact quaternion derivative is tangent to the unit quaternion three sphere.
A forward Euler method advances along the tangent line:
For unit qk,
Therefore
Hence
for a nonzero rate and nonzero step.
The norm defect is second order for one step but accumulates during repeated propagation.
9 Normalization
A common numerical correction is
Normalization restores the unit quaternion constraint and is generally appropriate after an
approximate propagation method or after finite precision arithmetic.
However, normalization does not make an approximate integration method identical to the exact
exponential update. It restores the manifold constraint but does not reconstruct higher order phase
terms omitted by the integrator.
For an exact unit incremental quaternion multiplying an exactly unit state, the product is
analytically unit:
Practical software may still normalize occasionally or every sample to control floating point
drift.
10 A numerically stable small angle evaluation
Directly evaluating
can lose numerical quality when Δ𝜃 is extremely small.
Its Taylor expansion is
Similarly,
A robust implementation may switch to such series below a small threshold.
11 Runge Kutta propagation
A higher order integrator can be applied directly to
For classical fourth order Runge Kutta,
and
The resulting quaternion should be normalized.
Runge Kutta methods are useful when an angular rate model can be evaluated inside the interval.
If an IMU supplies only one integrated delta angle per sample, the exact finite incremental
quaternion is often a more natural attitude update.
12 Exact update for a constant positive
rate
Suppose
and the body rotates at constant positive rate
Over one interval,
The increment is
After N equal intervals,
At a total positive frame rotation of 90∘,
This is the same passive convention diagnostic used throughout the preceding PhysicsLibrary
quaternion series.
13 Using IMU supplied delta angles
Many inertial sensors report integrated angular increments directly:
Such an output may already incorporate internal high rate sampling and manufacturer specific
coning processing.
If the bias estimate is expressed as an angular rate and is approximately constant over the sample,
a simple correction is
The corrected delta angle is then converted directly to the passive incremental quaternion.
The device documentation must be checked to determine whether its reported increment is raw,
internally compensated, expressed in a beginning sample frame, expressed in an ending sample
frame, or uses another convention.
14 Gyroscope bias accumulation
If an uncompensated constant gyro bias has magnitude b, then for a simple single axis case the
attitude error grows approximately as
For example, a bias of
accumulates approximately
of angle error in ten minutes.
This simple calculation explains why accurate bias initialization, online bias estimation,
temperature modeling, and external aiding are important in inertial systems.
15 Two successive body increments and coning
Consider two small chronological body frame increments
followed by
The passive incremental quaternions are
and
Because body increments left multiply, the chronological combined update is
Expand the increment product through second order:
The vector part of the last product is
Matching the passive first order form
gives the leading equivalent physical rotation vector
The cross product term is the leading coning contribution.
16 Why coning matters
If the body rotates alternately about different axes during a sample interval, the vector sum of the
measured increments is not generally the exact net rotation.
The missing information appears first through cross products of successive angular increments.
High accuracy strapdown inertial algorithms therefore use multiple subsamples or compensated
delta angles to account for noncommutativity.
A simple one sample exponential update is exact for a constant rotation vector over the interval. It
is not automatically exact for arbitrary high frequency motion occurring within that
interval.
If an IMU already reports a coning compensated delta angle, applying an additional naive coning
correction may double count the effect.
17 Attitude sign continuity
The unit quaternions
and
represent the same physical orientation.
A numerical quaternion time history may therefore contain equivalent samples with alternating
overall signs.
For plotting, interpolation, finite differencing, or optimization, choose the representative nearest
the previous sample.
If
replace
This does not change the physical attitude.
Sign continuity is a representation choice. It is distinct from quaternion normalization and from
selecting the principal error quaternion in a local attitude error calculation.
18 Specific force transformation
An accelerometer rigidly attached to the body reports specific force resolved in body
coordinates:
The passive attitude quaternion maps inertial coordinates into body coordinates, so the inverse
DCM maps body coordinates back into inertial coordinates:
Since
we have
The equivalent quaternion sandwich is
This inversion is important: the quaternion used for attitude propagation maps I → B, while
navigation mechanization often needs to rotate a measured body vector B → I.
19 Velocity and position propagation
In a simple inertial frame model,
and
In a rotating navigation frame, Earth rotation, transport rate, Coriolis terms, and the chosen
gravity model must also be included.
A typical strapdown propagation cycle is therefore:
- read gyroscope and accelerometer information;
- correct the gyroscope data for estimated bias;
- form or accept a corrected body delta angle;
- update the passive attitude quaternion;
- obtain an attitude appropriate to the accelerometer integration time;
- transform specific force from body coordinates into the navigation or inertial frame;
- add gravity and required rotating frame terms;
- integrate velocity and position;
- propagate bias and other estimator states.
20 Why time centered attitude can matter
Using only the beginning or ending attitude to transform accelerometer data introduces an error
when the body rotates appreciably during the sample.
For constant body rate, a midpoint quaternion can be formed as
where
The corresponding midpoint DCM can then be used for a simple time centered specific force
transformation.
High accuracy inertial algorithms develop this idea further through sculling compensation and
multiple sample integration.
21 Nominal quaternion and three component error state
A navigation filter can propagate the nominal attitude as a full unit quaternion while carrying only
three attitude error states.
For example, using the passive small error convention from the preceding article,
The nominal quaternion supplies a globally nonsingular orientation representation, while
is a local three component perturbation suitable for linear covariance propagation.
The chosen left or right error definition must remain consistent with the filter Jacobians and the
side used for correction injection.
22 Direct small increment versus error state small angle
The same small angle expansion appears in two distinct roles.
In direct IMU propagation,
approximates the actual physical incremental rotation during one sample. Its accuracy depends on
the size and variation of the sample motion.
In an error state filter,
represents a deliberately local estimation error around a nominal full attitude quaternion.
The nominal vehicle attitude itself may be very large even when the local error state is
small.
These two uses should not be conflated.
23 Normalization versus sign continuity
Two common operations have different purposes.
Normalization,
restores the unit norm constraint.
Sign continuity,
when needed, chooses one of two equivalent quaternion representatives.
Neither operation substitutes for an accurate attitude integration method.
24 Example propagation step
Suppose
and
The corrected rate is
For
the delta angle is
Therefore
Numerically,
Since the initial attitude is the identity,
25 Forward Euler comparison for the same step
The forward Euler result is
so
Its norm is
After normalization,
This is close to, but not identical with, the exact exponential result.
26 Implementation pseudocode
A minimal constant rate passive update can be expressed conceptually as:
omega_B = gyro_B - bias_hat_B
dtheta_B = omega_B * dt
a = norm(dtheta_B)
if a is very small:
s = 0.5 - a*a/48
c = 1.0 - a*a/8
else:
s = sin(a/2) / a
c = cos(a/2)
dq = [c, -s*dtheta_B]
q_new = dq * q_old
q_new = q_new / norm(q_new)
if dot(q_new, q_old) < 0:
q_new = -q_new
The product in the line
is the Hamilton product with scalar first semantic components.
Software whose array order is scalar last may use different memory indices without changing the
physical equations.
27 Common pitfalls
- Using the old inverse attitude convention.
The present PhysicsLibrary state is
not Iq
B.
- Using a positive vector part for a positive body frame increment.
The passive increment is
- Right multiplying body resolved increments.
For the passive inertial to body state,
- Assuming normalization makes Euler integration exact.
Normalization repairs norm, not truncation error.
- Ignoring gyro bias.
Even a small constant rate bias integrates into a large attitude error over time.
- Applying a simple vector sum to substantial multi axis motion.
Successive rotations do not commute. Coning terms matter.
- Applying coning correction twice.
Determine whether the sensor supplied delta angle already contains internal
compensation.
- Using the inertial to body quaternion in the wrong direction for
accelerometer data.
Body specific force is transformed to inertial coordinates with q∗ on the left and q on
the right, or with C(q)T .
- Interpreting quaternion sign flips as attitude jumps.
q and −q represent the same orientation.
- Treating the three component filter attitude error as the nominal attitude
itself.
The error vector is local; the nominal quaternion carries the global orientation.
28 Verification battery
A numerical implementation should be checked against:
- zero angular rate;
- constant positive rotations about +x, +y, and +z;
- exact exponential propagation from the identity;
- equality of C(qk+1) with the equivalent DCM increment;
- preservation of unit norm for exact increments;
- expected norm drift for unnormalized forward Euler;
- gyro bias accumulation;
- body increment multiplication on the left;
- sign continuity with q versus −q;
- two noncommuting increments and the leading coning term;
- specific force transformation with the inverse attitude map;
- consistency with the passive error state sign from Q12.
29 Relationship to adjacent PhysicsLibrary entries
The preceding article, Relative Attitude and Error Quaternions, establishes multiplicative left and
right errors and the passive local relation
The present article combines that convention with the quaternion kinematics from quaternion
kinematics and angular velocity to form sampled IMU attitude propagation.
A separate companion entry, Numerical Quaternion Propagation and IMU Attitude State
Integration: Examples, Exercises, and Solutions, provides the Q13E self study problem
bank.
30 Sources and convention notes
Quaternion propagation equations cannot be imported safely without identifying the
represented frame map, the resolution of angular velocity, and the quaternion multiplication
convention.
Sommer and coauthors provide a modern discussion of convention management. Solà provides a
detailed treatment of quaternion kinematics and IMU error state filtering. Titterton
and Weston provide a broad engineering treatment of strapdown inertial navigation.
Savage develops the classical strapdown attitude integration framework, including coning
compensation.
The equations in this entry are translated into the PhysicsLibrary passive inertial to body
convention.
References
[1] H. Sommer, I. Gilitschenski, M. Bloesch, S. Weiss, R. Siegwart, and J. Nieto, “Why
and How to Avoid the Flipped Quaternion Multiplication,” Aerospace, vol. 5, no. 3,
article 72, 2018. Published under CC BY 4.0. Publisher article
[2] J. Solà, “Quaternion Kinematics for the Error State Kalman Filter,”
arXiv:1711.02508, 2017. arXiv preprint
[3] D. H. Titterton and J. L. Weston, Strapdown Inertial Navigation Technology, 2nd ed.,
The Institution of Engineering and Technology, 2004/2005. Engineering reference. IET
book page
[4] P. G. Savage, “Strapdown Inertial Navigation Integration Algorithm Design Part 1:
Attitude Algorithms,” Journal of Guidance, Control, and Dynamics, vol. 21, no. 1, pp.
19–28, 1998. DOI record
License
Unless otherwise noted, this PhysicsLibrary entry is intended for release under the Creative
Commons Attribution ShareAlike 4.0 International license.