ozzmaker / BerryIMU

Code related to BerryIMU
http://ozzmaker.com
184 stars 108 forks source link

Correct Y readings with X==90 degrees? #6

Closed kramer65 closed 7 years ago

kramer65 commented 7 years ago

When I run the code from python-BerryIMU-gryo-accel-compass/berryIMU.py and tilt the BerryIMU 90 degrees to the right I would expect Y to be around 0, but instead it goes to about 100.

I asked a question about this behaviour on robotics.stackexchange, and the answer I got was that the problem was "estimating angles in regions of instability" in which they suggest to "modify unstable equations".

Can you confirm that this is the problem I'm having? Furthermore, I'm kinda lost in the maths they present, but do you have a suggestion how to incorporate this in your code?

mwilliams03 commented 7 years ago

This is the formula you can use to get around this issue pitch = atan2(x, sqrt(y y) + (z z)); roll = atan2(y, sqrt(x x) + (z z)); pitch = 180.0 / PI; roll = 180.0 / PI;

russellhoff commented 6 years ago

Which are the units for roll and pitch values? I guess they're in degrees...