# The Value of Quaternions - Why they are Important?

• Read 889 times
/19th March 2018,  Dr. Peter Jacquemin, DRONE MARKET WATCHTM/ The quaternion mathematical construct is an effective method to determine the attitude or angular position of rotating bodies in three-dimensional space. The quaternion approach provides a complete solution in comparison to the Euler method which can produce an error when large angle rotations enter into adjacent quadrants. Three-dimensional space rotation is within eight quadrants and one-dimensional space rotation is within four quadrants which poses an ambiguity for inverse cosine and sine trigonometric operations when dealing with three-dimensional space.

Quaternion and Euler transformation matrices relate a pointing vector on the rotating body to a fixed stationary coordinate frame or inertial based coordinate frame. The quaternion method uses a four-component vector instead of the three-component vector convention of the Euler method to describe the relationship of a rotating body relative to a fixed body.

Quaternion approach vs Euler Method

Quaternion mathematical operations employ complex variable algebra with a real part and an imaginary part composed of a three-dimensional (i,j,k) Euclidean space vector. The error in the Euler solution is due to an ambiguity in the cosine and sine trigonometric functions which does not account for an eight quadrant system describing three-dimensional space. A four-component quaternion vector and the corresponding solution for attitude determination (i.e. transformation matrix) can define the angular position of a rotating body for any rotation angle in three-dimensional space with no ambiguities or errors.

A typical quaternion-based navigation and attitude stabilization system uses angular rates or rotational velocities from gyro sensors. These gyro measurements are combined with quaternion vector components to produce a quaternion rate. The quaternion rates are then integrated and arranged to formulate the 3x3 transformation matrix which converts a body space vector to a fixed stationary coordinate frame (or inertial referenced coordinate frame). This transformation is especially important when relating the drone attitude to the ground.

Gyros are typically used in drones to control the roll-pitch-yaw or attitude/heading rates in order to stabilize the drone or air vehicle for pilot commands. Prior to the advent of the Global Positioning System (GPS), gyros were the sole means of inertial navigation by computing air frame position vectors based on air speed or aircraft velocity, attitude and heading. Prime deficiencies with GPS are low-resolution altitude determination, slow update information and no direction determination for a slow-moving drone. A stationary hovering drone can pivot in yaw or heading and this change in direction will not be detectable/discernable by GPS.

Application of quaternion approach in satellites, aircraft, drones, rockets and video games

Systems such as satellites, aircraft, drones, rockets and video games use quaternions to determine the instantaneous attitude or Line-of-Sight (LOS) vector to a ground target or to relate a spinning body relative to a fixed body or stationary viewer. Satellites use star trackers to reference the attitude for their gyros and to periodically correct the attitude reference due to gyro drift error. Ground mapping applies a scanned LOS vector from an aircraft, drone or satellite to register a hyperspectral imaged map onto the earth, for example. Robotics arms can also use quaternions for forward and inverse kinematics of the end effector position and angle. Any time body rotations occur over large angles, quaternion transformations provide the preferred solution over Euler matrix solutions.

The Euler solution uses cosine and sine trigonometric operations for a three-component vector solution while the quaternion solution uses a four-component vector. The issue with the Euler solution is the ambiguity of determining the quadrant that the vector lies in. For example, the cos-1(0.707) is either +45° in quadrant i or -45° in quadrant iv. Taking the sin-1(0.707) will provide the determination of the quadrant where a positive value sets the angle in quadrant i at +45° and a negative value sets the angle in quadrant iv at -45°. If an object is spinning or rotating in three dimensions, there are eight quadrants and no way to determine the quadrant that the rotated frame vector lies in. In the early days of flight navigation airplanes would crash due to the ambiguity error of the Euler transformation matrix.

Origination of quaternions

When William Rowan Hamilton, an Irish mathematician, derived quaternion mathematics in 1843 and discovered the fundamental formula for quaternion multiplication i2 = j2 = k2 = i*j*k = -1, he was so inspired that he carved the key mathematical relationship onto the side of a bridge. William Hamilton added a fourth vector component to a Euclidean cartesian vector (i,j,k) and related the fourth vector component as the real part of an imaginary variable and the other three components as the imaginary parts of an imaginary variable. Based on principles of complex number operations and vector products using quaternion vectors, Hamilton was able to derive a 3x3 transformation matrix that is identical in value to the Euler 3x3 transformation but remains stable with no ambiguity error for three-dimensional rotations of a body.

The quaternion uses an Euler rotation sequence of roll-pitch-yaw, yaw-pitch-roll, roll-pitch-roll or any combination of rotation sequences to initialize the quaternions. This feature is especially advantageous to drones for increasing the accuracy of mapping or pointing a LOS direction to a target.

Relationship of quaternions to gyros

Instead of updating the quaternion reference at a calibration station over long intervals of time, the quaternion can be updated more frequently during flight using the Euler rotation sequence to quaternion vector relationship. The U.S. Navy uses the lowest drift error mass-spinning gyros that are re-calibrated over months at a time, and the drift error will out by only a few degrees. This accuracy is not possible using Micro Electro-Mechanical Systems (MEMS) gyro technology so more frequent periodic re-calibration is required. MEMS based gyros exhibit significantly higher drift rate error than mechanical mass-spinning gyros, fiber-optic gyros, and ring-laser gyros. The Hubble Space Telescope uses the most precise mass-spinning gyros which provides for pointing stability that holds the telescope line-of-sight onto dark matter for weeks at a time.

The U.S. Navy uses a docking station to update the attitude/heading calibration reference for their gyros which is not possible when considering in-flight gyro re-calibration for a drone. In-flight calibration requires additional sensors to provide for correction of the gyro drift. An inclinometer or tilt sensor can be used for instantaneous attitude measurement and a magnetometer can be used for instantaneous heading measurement during flight. This solution works well for drones that do not perform aerobatics such as loops and barrel roll maneuvers. In the case of aerobatics, the attitude reference will rely on the integrated gyro rates. The attitude (tip-tilt or roll-pitch) sensors and the heading (yaw) sensors need to be more accurate than the gyros between attitude/heading reference updates in order to be effective.

More accurate LOS control for aerial mapping and target tracking can be achieved given MEMS technology gyros combined with attitude/heading sensors (aka sensor fusion). For more details on mathematical derivations and software algorithms on quaternions please visit http://dronegnc.com and select “quaternions”.