Attitude-Estimation icon indicating copy to clipboard operation
Attitude-Estimation copied to clipboard

handling inversion

Open belm0 opened this issue 7 years ago • 1 comments

The imu get_acc_angles() function output is incorrect when the IMU is inverted (phi and theta converge back to 0).

It seems to be due to loss of sign in the 2nd argument to the atan2 calls. I'd like to figure out how to correct it.

https://github.com/pms67/Attitude-Estimation/blob/44a4970d33268dc9ac06fc548e2935200238ffd3/imu.py#L48-L52

Thank you for the excellent article and sample code!

belm0 avatar Nov 16 '18 03:11 belm0

This seems to work (from https://stackoverflow.com/questions/3755059/3d-accelerometer-calculate-the-orientation):

phi = math.atan2(ay, az)

However from https://www.nxp.com/files-static/sensors/doc/app_note/AN4248.pdf, there also seems to be a different way to compute theta:

phi = math.atan2(ay, az)
theta = math.atan2(-ax, ay * math.sin(phi) + az * math.cos(phi))

belm0 avatar Nov 16 '18 04:11 belm0