Is the "complementary filter" comprising accelerometer and integrated gyro measurements a real representation of what is happening? The theory is that gyro measurements alone are inadequate for doing things like balancing an inverted pendulum so a complementary filter is needed.
But there are two reasons to doubt this explanation. First, a gyro alone can balance a two wheeled robot. I do it all the time. Second, an accelerometer used as an inclinometer must be at rest to be accurate. An accelerometer will measure tilt but if accelerated laterally the tilt measurement will be corrupted. Imagine being in a boxcar and measuring tilt with a plumb bob. Tilt will deflect the plumb bob but so will lateral acceleration.
So, in balancing a two wheeled robot is lateral acceleration significant compared to tilt? The attached pdf shows the result of an experiment to answer the question. An MPU6050 IMU is used for accelerometer and gyro measurements. Independent acceleration measurement comes from quadrature wheel decoders. Recorded measurements come from a robot while balancing.
Measurement blows the complementary filter theory out of the water.
Complementary Filter.pdf (145 KB)