Balancing robot nightmare

Read down to where it says:

The ball-bearing pivot and angle sensor were replaced by a piezo-electric gyroscope and ADXL202 accelerometer mounted just above the motor deck. Those sensors were eventually replaced by a commerical inclinometer, the FAS-G from MicroStrain, also consisting of an ADXL202 accelerometer and a rate gyro, similar to the boards and kits available from rotomotion. This rear view shows the complete stack.
.............
The gyroscope and accelerometer are combined with complementary filters to provide an inertial reference sensor. The ADXL202 accelerometer provides accurate static tilt information, when the robot is not accelerating. The gyroscope can be integrated to provide accurate dynamic tilt information, but the integration tends to drift over time. Combining the two sensors provides a robust inertial measurement. The FAS-G IMU implements a "Weiner" filter to combine the two sensors into a single measurement. The sourceforge autopilot project. and the boards available from rotomotion.com use a "Kalman" filter. Some really good information on inertial measurement units is available from the sourceforge autopilot project.