This is a quick hack I made as a response to a challenge: Make a coffecup-holder which can be used in a boat which holds the cup horizontal in the rough sea. I got a 6DOF MPU from eBay (MPU6050 chip from InvenSense) and an Arduino Nano compatible microcontroller. The wood and rc-servos/battery was something I had laying around.
There are examples on the internet showing how to access the MPU6050. By using a Kalman filter the drift problem of the gyro can be handled. Taking the output from the Kalman filter as angles, we can counter-act by sending the opposite signed angle to the servos to keep the platform stable.
Software is pure C++ done from Atmel Studio, I2C & MPU6050 code borrowed from Jeff Rowberg. Servocontrol by me, but Kalman filter is an proprietary implementation.
Planned improvements for the next version is
o Better quality/finish on the woodwork
o Servo rates/min/max, zero-offsets etc. configurable via RS232, stored in EEPROM.
o Make an open-source project out of it.