The IMU sensor allows us to measure the orientation of the robot, as well as obtain an estimation of its position as it moves. The product page of the Dexter Industries IMU can be viewed at https://www.dexterindustries.com/product/imu-sensor/. The respective aspect of the sensor can be seen in the following image:
Image courtesy: Dexter Industries: https://shop.dexterindustries.com/media/catalog/product/cache/4/thumbnail/1800x2400/9df78eab33525d08d6e5fb8d27136e95/i/m/imu-sensor_mount2-800x800.jpg
In the following image, you can see it mounted on the GoPiGo3. To connect to the robot, you only have to plug it into either AD1 or AD2 on the GoPiGo board:
Image courtesy: Dexter Industries: https://shop.dexterindustries.com/media/catalog/product/cache/4/thumbnail/1800x2400/9df78eab33525d08d6e5fb8d27136e95/i/m/imu-sensor_gpg3_3.jpg
This IMU has nine degrees of freedom (DOF), plus temperature measurement capabilities. Let's talk about each sensor of the IMU and what kind of data they provide:
- Let's start with the simpler one, the temperature. This provides the ambient room temperature and can be used in combination with the rest of the sensors to create, for example, a temperature map of a room, by taking measurements at several locations as the GoPiGo3 covers the surface.
- The accelerometer is an absolute sensor because its value is always referred to as zero acceleration (static object). It provides a value for each of the three axes, X, Y, and Z:
- It is good for measuring the inclination of the robot (an angle whose cosine is the vertical acceleration divided by the value of gravity = 9.81 m/s²) and the free-fall condition, which is equivalent to a 90° ramp and is a vertical wall (gravity is continuously detected by the sensor—that is, 9.81 m/s², if the object stays in a horizontal plane).
- The accelerometer is not as accurate for the measurement of velocity because this value is not directly provided by the sensor. We can obtain it by performing the integral of the acceleration signal over time, which produces cumulative errors (drift), mainly coming from the sensor noise (electronics) and the measurement error itself. This is where the gyroscope comes into the picture to provide an accurate speed measurement.
- The gyroscope is a differential sensor that provides the three rotations (X, Y, and Z axes) with respect to an arbitrary reference. What they really provide is the rotation velocity. This means that they are accurate for measuring rotation velocities, but not good for measuring angular position (you have to integrate of the speed signal over time, accumulating measurement errors and sensor noise, thereby producing drift).
A six-DOF IMU will be one that combines the accelerometer (three DOFs) and gyroscope (three DOFs):
- The accelerometer accurately measures the inclination with respect to the vertical. It does not have drift in the medium/long term, but is not accurate for short-term measurements.
- The gyroscope accurately measures rotation velocities, but they have drift. This means that they are not good for medium/long-term measurements.
By combining the six values from the accelerometer and gyroscope, it is possible to obtain an improved measurement of the orientation. This is expressed by means of the Euler angles—α, β, γ—as shown in the following diagram:
Image courtesy: https://commons.wikimedia.org/wiki/File:Euler_angles_zxz_int%2Baxes.png, License CC BY-SA 4.0
Something's that's more commonly used than the Euler angles are the Tait-Bryan version or navigation angles, roll-pitch-yaw, which can be defined as follows:
Image courtesy: https://es.m.wikipedia.org/wiki/Archivo:Flight_dynamics_with_text.png, License CC BY-SA 3.0
These angles are obtained by applying a special filter, called a complimentary filter, to the sensor's signals. It works like this:
- For the signal from the accelerometer, it behaves as a low-pass filter since we trust its medium/long-term measurement.
- For the signal from the gyroscope, it behaves as a high-pass filter since we trust its short-term measurement.
Mathematically, the complimentary filter is expressed as follows:
Here, A and B has to sum 1. These constants are determined by the calibration of the sensor, and typical values include A = 0.98, B = 0.02. The complimentary filter offers very similar results to the Kalman filter, which is the best linear (unbiased) estimator (BLE) but more computationally intensive.
Now, we have three rotations (about the X, Y, Z axes), but they are not absolute angles just yet:
- Thanks to the accelerometer, the orientation with respect to the vertical is an absolute reference, but for the orientation on the horizontal plane we are lacking such a reference because the gyroscope is a differential sensor.
- This is where the magnetometer appears to give us the orientation (three axes X, Y, Z) of the Earth's magnetic field.
Therefore, with our 6 + 3 = 9 DOFs IMU, we have the absolute orientation of our robot, with the gravity and the magnetic field vectors as references. In Chapter 2, Unit Testing of GoPiGo3, we'll go over a specific test you can run with your robot to check that this unit works properly.