How does self leveling actually work? This is something I've been wondering for some time now.


Generally speaking, an FC has 3 gyros which measure angular rates, and accelerometers that measure acceleration along 3 axis. Using these sensors, the quad can approximate its current orientation and velocity, assuming it knew where it was before taking off. 


What I don't get is how the FC doesn't drift over time. The gyros measure rates, not orientation. The accelerometers can't "feel" when the craft is tilted either, because the apparent force of gravity is always in line with the lift vector. 


I noticed that my Phantom 2's auto level ("attitude") mode tends to get a bit wonky after flying aggressively for a while (doesn't return to level, pitch/roll control becomes unpredictable). But after a few seconds of hovering, it slowly gets its bearings and starts flying normally. (Attitude mode doesn't use the GPS, so it's not that) How does it accomplish this using only an IMU?