Theoremcore
Quaternion kinematic equation
Also called quaternion derivative.
For a unit quaternion q (Hamilton, scalar first) that maps body to world, dq/dt = (1/2) q (0, w_b) = (1/2) (0, w_s) q, a linear equation with no singular attitude.
The quaternion kinematic equation gives the rate of change of a unit quaternion attitude in terms of the angular velocity. For a unit quaternion in the Hamilton convention, with the scalar first, whose rotation maps body coordinates to world coordinates, it reads
where is the angular velocity in the body frame, is the same angular velocity in the world frame, and is a pure quaternion. The equation is linear in with coefficients that stay bounded, so it has no singular attitude, unlike the rate equations of roll-pitch-yaw angles. Gyroscope integration, attitude filters and simulators of rigid bodies use it.
Notation on this page: rotations are active, is the skew-symmetric matrix of , has the scalar part and the vector part , and the product of quaternions is .
Statement
Theorem. Let be a differentiable curve of unit quaternions, and let , so that . Define the body and the space angular velocities by and . Then
In matrix form, with as the column ,
Conversely, for every continuous and every unit , the linear equation has a unique solution, the solution keeps , and is the attitude that solves .
Other conventions. If maps world to body instead, replace by : then . In the JPL convention (scalar last, ), the products appear in the reverse order, and the body form becomes in that algebra. Many errors in practice come from a formula of one convention used with quaternions of another, so state the convention next to the equation.
In plain words
A quaternion stores an orientation with four numbers. When the body turns, the four numbers change, and this equation tells how fast. The rate is half of the current quaternion times the turning rate of the body, so it needs only a product and a scale. The factor one half comes from the fact that a quaternion stores half of the angle of a turn. The turning rate can be measured in the body, as a gyroscope does, or in the world, and the product is then taken on the right or on the left. Nothing in the equation divides by a quantity that can be zero, so it works at every orientation. A computer that steps the equation in time slowly lets the length of the quaternion drift from one, so it rescales the quaternion after each step.
Proof
Step 1: the derivative of a unit quaternion. Put . Differentiating gives , so the scalar part of is zero and for some . Then .
Step 2: is the body angular velocity. Differentiate for a fixed . With and ,
For pure quaternions, , so . So , that is , and . This proves .
Step 3: the space form. , because . So , and .
Step 4: the matrix forms. The vector part of is , and the scalar part is . For the vector part is .
Step 5: the converse. The equation is linear with a continuous coefficient, so it has a unique solution on . The matrix of Step 4 is skew-symmetric, so , and stays 1. Step 2 then applies to the solution and shows .
A check by hand
Take a constant and , the rotation by about . Then . The product has the scalar part and the vector part , since is parallel to . So . Here turns about its own axis, so , and the space form gives the same result.
Consequences
- Integration over a step. For a constant over a step of length , the exact solution is with . This step keeps up to rounding, and it is the usual way to integrate gyroscope samples.
- The forward Euler step drifts. The step multiplies by . At rad/s with s, after steps, , and after normalization the angle is short by rad, while the exact step above is wrong by rad. Normalize after each step of an Euler or Runge-Kutta method.
- No gimbal lock. The rate equations of roll-pitch-yaw angles divide by the cosine of the pitch and fail at the gimbal lock. The quaternion equation has no division, so dead reckoning and attitude estimation use it for all attitudes.
- Filters. The prediction step of the error-state Kalman filter integrates this equation for the nominal attitude, and the nonlinear complementary filter adds a correction term to before it integrates.
- Constant angular velocity gives slerp. For a constant , the solution is , which is the path of spherical linear interpolation between its end points.
Tightness
- The factor one half. It cannot be dropped: the quaternion of a rotation by uses , so would turn the body at twice the true rate.
- The side of the product. The body form needs on the right and the space form needs on the left. With on the left, the result is correct only when is parallel to the axis of , as in the check by hand, where .
- The unit constraint. For a quaternion with , the equation still holds for , because the norm is constant along every solution. Numerical methods do not keep the norm, so the normalization step is needed in practice, not in theory.
- A nonlinear map in disguise. The equation is linear in , but the map from to is quadratic, and and give the same attitude. A filter that compares quaternions must choose the sign first.
History
William Rowan Hamilton found the quaternions in 1843 and published them from 1844. The kinematic equation is the derivative of his rotation formula . Sola collects the Hamilton and the JPL forms of the equation and the integration methods built on it.
References
- Joan Sola, Quaternion kinematics for the error-state Kalman filter, 2017, Section 4.5 (the time derivatives, equations 200 and 201, and Section 4.5.1 on global and local angular velocities) and Section 4.6.1 (zeroth-order integration, equation 215)
- Kevin M. Lynch and Frank C. Park, Modern Robotics, Mechanics, Planning, and Control, Cambridge University Press, 2017, Chapter 3, Section 3.2.2 (angular velocities in the space and the body frames)
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag F6CXDF Edit this page History Report an error Markdown