(Python) I am using an IMU (Inertial Measurement Unit) attachated to a raspberry pi that provides angles of [roll, pitch, yaw].
The chip seems to have a hardware 'zero' and cannot calibrate it, therefore in software I want to.
i.e. When I turn on the chip I may get a reading of theta = [10, 5, -80]
* and want to set that to my 'zero'.
*the angles are in the range +- 180deg and can be in rad if easier
I have a crude workaround but am after something more elegant:
tare = [*read initial angles*] # This only gets set once
#inside a loop
theta = [*read the imu*]
deg = map(operator.sub, theta, tare) #zero correction, deg = actual (theta) - 'zero' (tare)
for d in deg: # if angle > 180 then put angle in terms of +_ 180
if d > 180: d = d - 360
elif d < -179: d = d + 360
print deg
Ive been looking into this for a while now and some people have mentioned quaternions and rotation matrices but I cant get my head around it. Any help would be much appreciated!
Here is a link to someone achieveing it in c++ for the same Lib I am using to get the data from the IMU: Link
Other potentially useful (stackoverflow) link: Link