7. How to make a Balboa balance
Balancing a two-wheeled robot like the Balboa is a classic problem in control theory, known as the
“inverted pendulum”, and there are many approaches to solving it. This section discusses the simple
balancing technique in the Balboa
[https://github.com/pololu/balboa-32u4-arduino-library/
tree/master/examples/Balancer]
, which uses feedback from the Balboa’s gyroscope and encoders to keep
the robot upright.
7.1. Sensor measurements
The key to balancing is the built-in ST
[https://www.pololu.com/product/2736]
IMU chip, which
combines a 3D gyroscope and a 3D accelerometer. The Balboa also includes an ST
[https://www.pololu.com/product/2737]
3-axis magnetometer. These nine sensor channels can be used in
software to make an
AHRS
(attitude and heading reference system), a system that gives the robot a
sense of its orientation in three dimensions. AHRS software is particularly important in aviation/drone
applications, but for basic balancing, you don’t need anything that complicated. In fact, a single gyro
channel – the y-axis – is enough to determine the robot’s angle of rotation relative to vertical.
The gyroscope’s y-axis channel measures the Balboa’s forward/backward rate of rotation, in units
such as degrees per second. To keep track of its total rotation angle, you need to integrate the gyro
reading: periodically check the sensor and multiply the rate of rotation by the time period. Here is the
main gyro-related code from our Balboa
[https://github.com/pololu/balboa-32u4-arduino-
library/tree/master/examples/Balancer]
Pololu Balboa 32U4 Balancing Robot User’s Guide
© 2001–2019 Pololu Corporation
7. How to make a Balboa balance
Page 78 of 97