Algorithm Search⌘K

Problemcore

Attitude estimation

Also called orientation estimation.

Estimate the orientation of a body from gyroscopes, accelerometers, magnetometers or star sensors.

Attitude estimation asks for the orientation of a rigid body, a rotation in the special orthogonal group SO(3)SO(3), from sensors that see directions or rates. Vector sensors, such as an accelerometer that sees gravity, a magnetometer, a sun sensor or a star tracker, give the body-frame form of known directions. A gyroscope gives the angular velocity, which must be integrated. With vector sensors alone at one instant, the problem is Wahba's problem, a static least squares fit. With a gyro and a time series, it is a case of state estimation on a curved space, and filters on SO(3)SO(3) solve it. The position analog is mobile robot localization, and integrating the gyro alone is the rotational half of dead reckoning.

In plain words

You want to know which way an object points: a phone, a drone, a satellite. Some sensors tell you where fixed things are as seen from the object, such as which way is down or which way is north. Two such directions, if they are not parallel, are enough to fix the orientation, but each reading is noisy. Another sensor tells you how fast the object turns. Adding up the turns gives a smooth estimate, but small errors pile up and the estimate drifts. Good methods combine the two kinds of sensor: the turn rate for short-term motion and the fixed directions to stop the drift.

Definition

Write R=RsbR = R_{sb} for the attitude, the rotation that takes body coordinates to space coordinates. It follows R˙=R[ω]×\dot R = R [\omega]_\times, with ω\omega the body angular velocity.

Static problem. Given unit directions rir_i known in the space frame, their body-frame measurements bi≈RTrib_i \approx R^T r_i and weights ai>0a_i > 0, for i=1,…,ni = 1, \ldots, n, find R∈SO(3)R \in SO(3) that minimizes 12∑iai∣bi−RTri∣2\tfrac{1}{2} \sum_i a_i |b_i - R^T r_i|^2. This is Wahba's problem.

Dynamic problem. Given a gyro signal ωm=ω+β+n\omega_m = \omega + \beta + n, with a slowly varying bias β\beta and white noise nn, and vector measurements bi(t)≈R(t)Trib_i(t) \approx R(t)^T r_i at some times, estimate R(t)R(t) and often β(t)\beta(t), online. A stochastic version asks for the conditional distribution of R(t)R(t), or at least a mean and covariance; a deterministic version asks for an observer whose error converges to zero when the data are exact.

The orientation can be stored as a rotation matrix, a unit quaternion or a rotation vector. Euler angles are common in interfaces but have gimbal lock, so estimators avoid them internally.

Variants

  • Single snapshot or sequence. A star tracker often gives enough directions for a static solution at each frame; an inertial unit on a robot usually needs a filter.
  • Attitude and heading reference. Gyro, accelerometer and magnetometer. The accelerometer gives gravity only when the body does not accelerate.
  • With gyro bias. The bias is a slow state that the filter must estimate; without vector measurements, it is not observable.
  • Full navigation. Attitude with position and velocity, from an inertial unit and position fixes. Attitude is then one block of a larger filter.
  • Reduced attitude. Only the direction of one vector matters, for example the tilt from gravity; the rotation about that vector is left free.

Examples

  • A phone lies flat and points north. The accelerometer reads gravity as (0,0,1)(0, 0, 1) in the body frame (up to sign and scale) and the magnetometer reads a vector in the body xx-zz plane. TRIAD on these two directions gives the identity attitude.
  • A gyro with white noise of standard deviation σ\sigma per sample, integrated over t/δtt / \delta t samples of length δt\delta t, has an angle error with standard deviation σδt t\sigma \sqrt{\delta t \, t} per axis (theorem for independent noise samples; Woodman 2007, Section 3.2.2). A constant bias β\beta adds an error βt\beta t that grows linearly.
  • The nonlinear complementary filter page shows a filter that recovers from a 107 degree error with exact data, and the error-state Kalman filter page shows one that settles near 1 degree with noisy data.

Known algorithms

Static, from one set of vector measurements:

  • TRIAD. Two directions, closed form, exact for exact data but not optimal with noise.
  • Davenport's q-method. The optimal quaternion is the top eigenvector of a 4×44 \times 4 symmetric matrix.
  • QUEST. The same optimum by Newton's method on the characteristic polynomial, with a closed-form eigenvector.

Dynamic, from a gyro and vector measurements:

  • Nonlinear complementary filter. A deterministic observer on SO(3)SO(3) with a gyro bias estimate and an almost-global stability proof. Two gains, no covariance.
  • Error-state Kalman filter. The multiplicative extended Kalman filter: a nominal quaternion and a three-angle error in a Kalman filter. The standard choice when a covariance is needed.
  • Invariant extended Kalman filter. An EKF on a matrix Lie group with an invariant error, whose error propagation does not depend on the estimate.
  • Gyro integration only. The quaternion kinematic equation integrates the rate; it is exact for a constant rate over a step, but it drifts.

Other filters, such as the unscented Kalman filter and the particle filter, are also used on the same state.

AlgorithmTimeSpacePropertiesCode
Error-state Kalman filterO(T + m) worstO(1) extradeterministicnot exactonlinerecursive1 language
Nonlinear complementary filter on SO(3)O(T n) worstO(1) extradeterministicnot exactonlinerecursive1 language

Bounds

  • Observability (theorem). Two non-parallel directions determine the attitude uniquely when the data are exact. One direction leaves the rotation about it free. Proof: if R1Tri=R2TriR_1^T r_i = R_2^T r_i for two non-parallel rir_i, then R2R1TR_2 R_1^T fixes two independent vectors, so it also fixes their cross product, and it is II.
  • Static covariance (theorem, to first order). With measurement noise of variance σi2\sigma_i^2 per axis perpendicular to bib_i, and weights ai=1/σi2a_i = 1 / \sigma_i^2, the optimal static estimate has an error covariance close to (∑iai(I−bibiT))−1\left(\sum_i a_i (I - b_i b_i^T)\right)^{-1} in body angles, when the noise is small (Markley and Crassidis, 2014, Chapter 5). The matrix is invertible exactly when two of the bib_i are not parallel.
  • Gyro drift (theorem). For white rate noise the angle error grows as t\sqrt{t}; for a constant bias it grows as tt. Vector measurements bound the error; without them it is unbounded.
  • Topology (theorem). No continuous observer on SO(3)SO(3) can make the true attitude a globally asymptotically stable equilibrium, because SO(3)SO(3) is not contractible. Almost-global convergence, as in Mahony et al. (2008), is the best possible.

Reductions

  • The static problem reduces to a 4×44 \times 4 symmetric eigenproblem (q-method) or a 3×33 \times 3 singular value decomposition, and it is the same as the rotation part of the Kabsch algorithm for point sets.
  • The dynamic problem with a gyro is a Bayes filter on SO(3)SO(3), or on SO(3)×R3SO(3) \times \mathbb{R}^3 with the bias. Kalman filters approximate it with a mean and a covariance of a small error.
  • A static solution can serve as the measurement of a filter, which turns the vector measurements into one attitude measurement.

Applications

Spacecraft attitude determination with star trackers, sun sensors and gyros; drones and other aerial robots, where the attitude feeds the flight controller; phones, game controllers and headsets; legged robots, which need the direction of gravity for balance; and the inertial part of visual-inertial and lidar-inertial odometry.

References

  1. F. Landis Markley and John L. Crassidis, Fundamentals of Spacecraft Attitude Determination and Control, Springer, 2014, Chapter 5 (static attitude determination) and Chapter 6 (sequential attitude filtering)
  2. Grace Wahba, A least squares estimate of satellite attitude, SIAM Review 7(3), 1965, Problem 65-1, the statement of the static least squares problem
  3. Robert Mahony, Tarek Hamel and Jean-Michel Pflimlin, Nonlinear complementary filters on the special orthogonal group, IEEE Transactions on Automatic Control 53(5), 2008, Section V (the explicit complementary filter with gyro bias)
  4. E. J. Lefferts, F. L. Markley and M. D. Shuster, Kalman filtering for spacecraft attitude estimation, Journal of Guidance, Control, and Dynamics 5(5), 1982, pages 417 to 429, the attitude filters with a reference quaternion and gyro bias
  5. Oliver J. Woodman, An introduction to inertial navigation, Technical Report UCAM-CL-TR-696, University of Cambridge Computer Laboratory, 2007, Sections 3.2.1 and 3.2.2 (gyro bias and white noise, and the angle errors they cause)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a contract.yaml