Got Quaternions?

If you have an IMU or other sensor that produces something called Quaternions, you might want to use them to track the orientation of your robot as it moves in all 3 dimensions. The RoboBees Team 836 is releasing LabVIEW software that converts between quaternions and more conventional Euler Angles (such as Roll, Pitch, and Yaw) since these conversions don’t currently exist in the LabVIEW or WPI libraries.

The three-dimensional spatial orientation of an object can be expressed using quaternions. The quaternion is an extension of complex numbers, from one of the less mainstream branches of mathematics. (The quaternion represents a point on the surface of a four-dimensional hyper-sphere.) You can think of a quaternion as a complex number, which has real and imaginary components, where each of these components is itself a complex number. One could say a quaternion is a hyper-complex number!

Quaternions are useful in avoiding mathematical singularities like gimbal lock and for smoothly interpolating rotations, and quaternion data may be produced by Inertial Measurement Unit (IMU) sensors. Unit quaternions, where the root-sum-square of all elements is one, are always used for rotation applications. Sir William Hamilton is credited with the discovery of quaternions in 1843. They’re used extensively today in computer gaming applications.

The software is attached. There is a Quaternion to Euler conversion vi as well as a Euler to Quaternion conversion vi. There is also a Test vi that allows one to explore the conversion process. Just unzip the file, load the Project File and run QuaternionTest. Bunch of documentation included to understand the process and code.

In addition to the conversion software, I thought I would share a document I received during my research. It tells the story how the Odyssey orbiter maintained real time communication with Curiosity during its dramatic descent to Mars. It has great engineering story elements - equipment failure complicated by manufacturing issues overcome by creative maneuvers to achieve the objective under a hard deadline … (sound familiar?). Hamilton would be amazed, I think, at this application of his research, how mission success depends so critically on ‘the right rotation’!

The document is authored by Noel Hughes, a senior aerospace engineer for Lockheed Martin. It was his algorithm that I referenced to create the quaternion conversion code, which I am thankful for.

A good illustration of where a STEM career can take you. The RoboBees look forward to seeing you on the field of STEAMworks!

Quaternion (104 KB)
AAS paper01_05.pdf (2.78 MB)

Quaternion (104 KB)
AAS paper01_05.pdf (2.78 MB)

Hi Richard,

We at Kauai Labs thought the same thing. The navX-MXP and the navX-MICRO both output quaternions. We have also developed a complete library to use these components called the Sensor Fusion Framework (SF2) to correct for video latency. The libraries can be found here. We have a full library of quaternion math functions as well as the convert to yaw, pitch and roll. THe library is written for LabVIEW, Java and C++.

The link on Chief Delphi for complete libraries for navX and SF2 (Sensor Fusion Framework) are available here:

You do not need to use the navX to take advantage of the SF2 libraries. It has been written to take advantage of the navX but can be modified to use other third party sensors.