The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

(singke) #1

180 THE OFFICIAL RASPBERRY PI BEGINNER'S GUIDE


Inertial sensing
The gyroscopic sensor, accelerometer, and magnetometer combine to form what is known
as an inertial measurement unit (IMU). While, technically speaking, these sensors take
measurements from the surrounding environment just like the environmental sensors – the
magnetometer, for example, measures magnetic field strength – they’re usually used for data
about the movement of the Sense HAT itself. The IMU is the sum of multiple sensors; some
programming languages allow you to take readings from each sensor independently, while
others will only give you a combined reading.
Before you can make sense of the IMU, though, you need to understand how things move.
The Sense HAT, and the Raspberry Pi it’s attached to, can move along three spatial axes:
side-to-side on the X axis; forwards and backwards on the Y axis; and up and down on the Z
axis (Figure 7-25). It can also rotate along these three same axes, but their names change:
rotating on the X axis is called roll, rotating on the Y axis is called pitch, and rotating on the
Z axis is called yaw. When you rotate the Sense HAT along its short axis, you’re adjusting its
pitch; rotate along its long axis and that’s roll; spin it around while keeping it flat on the table
and you’re adjusting its yaw. Think of them like an aeroplane: when it’s taking off, it increases
its pitch to climb; when it’s doing a victory roll, that’s literally it spinning along its roll axis; when
it’s using its rudder to turn like a car would, without rolling, that’s yaw.

Pitch: Y


Roll: X


Yaw: Z


5 Figure 7-25: The spatial axes of the Sense HAT’s IMU
Free download pdf