Detecting Orientation with an IMU on Raspberry Pi Pico
Our robot can track how far it’s moved, but what about tracking which direction the robot is facing? Or how far it has turned? In this chapter, we will learn about the Inertial Measurement Unit (IMU), a device that can track the motion of the robot measured against gravity and the Earth’s magnetic field.
We’ll look at how to select one of these devices, get it connected and then write code for it on our robot using the PID controller to steer the robot based on the IMU data.
In this chapter, we will cover the following main topics:
- What is an IMU and how to choose one
- Connecting the IMU to the robot
- Calibrating and getting readings
- Always face North behavior
- Making a known turn behavior