I'm having some trouble with orientation calculation, it's easiest explained by looking at the video below. I'm using a gy-80, so the accelerometer is an L3G4200D and gyro is a ADXL345. It seems to track movements pretty well, until it's tilted over + or - 90 degrees, at which point the opposite direction flips 180 degrees (so if Pitch is over 90 then roll flips 180).
The trouble seems to be the accelerometer values, is it possible? I'm calculating pitch and roll as follows, as from Lazurus's guide - also using his kalman filter:
I'm having the same problem and I cant find a solution to this.
The left column are my roll values, the left column are my pitch values. They are the result of this calculation:
roll = (atan2(ay, az)+PI)*RAD_TO_DEG;
pitch = (atan2(ax, az)+PI)*RAD_TO_DEG;
(ax, ay, az are accelerometer measurements)
I rotated my device around the X-axis (should only change my roll value). I did not rotate around the y-axis, so my pitch should theoretically stay at ca. 180 degrees all the time… but it doesn't!
Red is the part where it gets strange….