How to Measure Angular Motion with a Gyroscope

0 Comments
Share This
Share This

Measuring angular motion can be important in a wide variety of applications, including sports biomechanics and astronomy. In this blog post, I'll go over how to define rotation and what's needed to calculate angular velocity. I’ll then walk you through how to measure rotation and what’s required (including formulas) to calculate angular velocity with an accelerometer. There are a variety of accelerometers and DAQ systems that can help measure both orientation and acceleration, but for this post I’ll be using one of my company’s enDAQ sensors, as it comes equipped with in-built gyroscopes and accelerometers.

I'll cover:


Reference Frames

In order to define rotation (and by extension angular velocity and acceleration) it is first necessary to define some terms:

Vector Basis

A vector basis is a set of non-coplanar vectors that are used to define orientation. Vector bases may have additional properties such as:

  • Orthogonal - the basis vectors are mutually orthogonal. Orthogonal vector bases are also rigid by definition
  • Normal - all of the basis vectors are unit vectors
  • Rigid - the angles between the basis vectors are constant. This introduces a sense of time to the basis since time must be defined in order for the angles to not change over time.
An example of a 3D orthonormal vector basis is the i,j, and k with hats unit vectors unit vectors that form a basis in R3.

Reference Frame

A reference frame is an infinite set of non-collinear points where the distance between any two points is constant. Once again, the term constant implies a sense of time. Reference frames define both position and orientation. A convenient way to define a reference frame N is using a point and an orthonormal vector basis fixed in N. Reference frames can be Newtonian or non-Newtonian:

  • Newtonian Reference Frame - (also known as an inertial reference frame) a non-accelerating (this includes non-rotating) reference frame in which Newtonian Reference Frame  accurately predicts all motion. The Earth is a non- Newtonian reference frame, however it can often be approximated as a Newtonian reference frame.
  • Non-Newtonian Reference Frame - an accelerating reference frame in which Non-Newtonian Reference Frame  does not apply.

For the purposes of this guide, we will restrict our focus to 3D orthonormal vector bases. Orientation and its derivatives (angular velocity and acceleration) can be defined without specifying any points, so they can be defined in terms of a pair of vector bases. Since reference frames contain vector bases, orientation can also be defined in terms of two reference frames. Position and its derivatives (velocity and acceleration) are defined between two points, and thus require at least one reference frame to be defined.


Orientation

The orientation of a rigid body is defined by the alignment between a vector basis attached to the body and another vector basis or reference frame. For the purposes of this guide, we will consider the orientation of a body B (defined by orthonormal basis vectors orthonormal basis vectors b) in the world reference frame W (defined by orthonormal basis vectors orthonormal basis vectors w). There are several ways to define the orientation of B in W.

  1. Rotation Matrix - the rotation matrix bRw which is defined such that:
    Rotation Matrix
  2. Euler Angles - successive rotations about the b basis vectors. These rotations can be performed in any order such as XYZ or YZY .
  3. Euler Parameters (Quaternions) - Any rotation(s) that can be expressed using either of the two preceding methods can also be expressed as a single rotation θ about the unit vector lambda hat. lambda hat is fixed in both W and B for this rotation and θ is the angle between two arbitrary vectors a with arrow (fixed in W) and beta with arrow (fixed in B) which are initially equal. It should be noted that lambda hat is fixed for this rotation only, and is not guaranteed to remain fixed for subsequent rotations. Rotation using Euler parameters can be conveniently expressed and efficiently computed using quaternions.

Conversion between these forms can be accomplished using the formulas found in this NASA Technical Brief [2].


Quaternions

A quaternion is a hypercomplex number of the form

how to measure angular motion with an accelerometer equation 1 (1)

where

how to measure angular motion with an accelerometer equation 2 (2)

For the purposes of this document, quaternions will be expressed in bold font. A more convenient way to express (1) is as the sum of a scalar and a vector

how to measure angular motion with an accelerometer equation 3 (3)

There are several properties and definitions of quaternions that will be relevant to this analysis.

Table 1: Quaternion Properties and Definitions

Name Symbol Definition
Quaternion Conjugate Quaternion Conjugate symbol Quaternion Conjugate
Quaternion Norm Quaternion Norm symbol Quaternion Norm definition
Unit Quaternion  

Unit Quaternion definition

Pure Quaternion   Pure Quaternion definition
Quaternion Sum a + b quaternion sum definition
Quaternion Product ab quaternion product definition
Quaternion Time Derivative q dot

Quaternion Time Derivative definition

As mentioned previously, quaternions are a convenient way to express Euler parameters (theta hat lambda rotations). This can be done by re-writing (3) as the unit quaternion

how to measure angular motion with an accelerometer equation 4 (4)

Suppose that b a arrow is a vector in the body basis Bb a arrow can be expressed as the pure quaternion

how to measure angular motion with an accelerometer equation 5 (5)

Suppose also that the transformation between the body basis B and the world frame W is achieved by the rotation of θ about lambda hat, expressed with the unit quaternion q as defined in (4). Transforming a with arrow into the world frame W can be done using

how to measure angular motion with an accelerometer equation 6 (6)

This operation is known as a frame rotation, because the reference frame is rotating and the vector itself is unchanged. A proof for this relation can be found in [3].


Angular Velocity

The angular velocity of the body B expressed in the world frame W is denoted as how to measure angular motion with an accelerometer equation. When working with theta and lambda rotations, it is tempting to express the angular velocity of the rotating frame as

how to measure angular motion with an accelerometer equation  

however, this is only valid if lambda hatremains fixed in both frames! If lambda hat is changing, the angular velocity is

how to measure angular motion with an accelerometer equation 7 (7)
how to measure angular motion with an accelerometer equation 8 (8)

the proof of which can be found in [4]. Since lambda hat is a vector, it must be differentiated in a reference frame (or vector basis). It turns out that the time derivative of lambda hat is the same in both the world frame and body basis. Using (4), (7) can be written as

how to measure angular motion with an accelerometer equation 9 (9)

where how to measure angular motion with an accelerometer equation. This equation can be proven a number of different ways [1][3]. When solving (9) numerically, the real part of how to measure angular motion with an accelerometer equation may be nonzero, however this can be ignored to a reasonable approximation.


Acceleration

In addition to calculating the angular velocity, quaternions can also be used to transform the accelerometer data between reference frames. Acceleration is derived from position, and thus must be defined in a reference frame as opposed to a vector basis. The most convenient way to form a reference frame in this case is with a point and a vector basis. The choice of this point is arbitrary, as the acceleration of one reference frame in another does not depend on the absolute distance between any two points. Any vector, such as acceleration, can be transformed from one reference frame to another using Equation (6).

It should be noted that the world reference frame is a non-Newtonian reference frame due to the rotation of the earth. This effect may or may not be relevant to your measurements, depending on the application and length of data acquisition.


Application to enDAQ Sensors

enDAQ sensors feature an IMU unit that outputs orientation in the form of an array of quaternions. These quaternions provide the enDAQ sensor vector basis D (defined in Figure 1) in one of two possible reference bases at each data acquisition point.

s4-enDAQ-sensor-orientation

Figure 1. enDAQ S4 Sensor with basis vectors labeled

The two possible reference bases are related to how the orientation is calculated by the IMU:

  1. Absolute Orientation - The orientation is calculated using the gyroscope with corrections from the accelerometer and the magnetometer. The reference basis is the world basis, W, which is formed by Wx pointing North, Wz pointing opposite the gravity vector, and Wy forming a right-handed system
  2. Relative Orientation - The orientation is calculated using the gyroscope with corrections from the accelerometer only. The reference basis D0 is coincident with the enDAQ sensor basis D at the first data acquisition point

More detail on the advantages and disadvantages of these two systems can be found in this enDAQ blog post: Quaternions for Orientation.

The gyroscope in the IMU measures the angular velocity and then integrates to find the orientation. This means that we can differentiate the orientation to find the angular velocity without worrying about amplifying the noise. Figure 2 compares the angular velocity calculated using (9) and the angular velocity measured directly by the IMU. It should be noted that the IMU in the enDAQ sensor cannot simultaneously provide the orientation quaternion and the raw IMU angular velocity, so the data in Figure 2 was taken by two enDAQ sensors mounted to the same rotating surface. The slight variation between them is a result of differing noise levels, as well as imperfections in the cross-correlation of the two signals.

QuaternionBlogPost_v2-2

Figure 2. Angular velocity calculated by differentiating the quaternion and pulled directly from the IMU

Acquiring Angular Velocity and Acceleration from an enDAQ Sensor IMU

  1. Format the enDAQ sensor by selecting absolute orientation or relative orientation.

  2. Acquire the data.

  3. Numerically differentiate the quaternion array to find q dot using
    how to measure angular motion with an accelerometer equationThese lecture notes give a good overview of finite difference methods of numerical integration.

  4. Calculate the angular velocity and acceleration of the enDAQ basis D in the reference basis A (where A is either the world basis W or the initial reference basis D0) numerically using Equation (9) and Table 1.
    how to measure angular motion with an accelerometer equation
    where how to measure angular motion with an accelerometer equation .

  5. The reference basis that you chose may not be the most convenient for expressing the angular velocity, so it can be transformed into a new basis N using
    how to measure angular motion with an accelerometer equationwhere q is the quaternion that describes the transformation between A and N.

Transforming enDAQ Sensor Acceleration Using Quaternions

The quaternion array can also be used to transform the acceleration data from the rotating enDAQ sensor reference frame into a stationary reference frame at each data acquisition point using

how to measure angular motion with an accelerometer equation

where how to measure angular motion with an accelerometer equation, D is the enDAQ reference frame and A is either the world reference frame W or the initial reference frame D0 depending on if the unit is in absolute or relative position mode.


Conclusion

So that is your overview of angular motion and how to use an enDAQ sensor to measure rotation and angular velocity. I hope you found it helpful. For more content like this, don't forget to subscribe to our blog and if you have any questions, don't hesitate to leave a comment below or contact us directly. 

Related Posts:

For more on this topic, visit our dedicated Environmental Sensors resource page. There you’ll find more blog posts, case studies, webinars, software, and products focused on your environmental testing and analysis needs.

New call-to-action


References

[1] Basile Graf. "Quaternions and Dynamics". en. In: arXiv:0811.2889 [math- ph] (Nov. 2008). arXiv: 0811.2889 [math-ph].

[2] D M Henderson. "Euler Angles, Quaternions, and Transformation Matrices". en. In: (1977), p. 42.

[3] Yan-Bin Jia. Quaternions. Sept. 2019.

[4] Paul Mitiguy. Advanced Dynamics and Motion Simulation. 2015.

Share This

Stanley Normile

Mechanical Engineer at Mide Technology

By signing up you are agreeing to our Privacy Policy