BHI160B Tare implementation to reset the quaternions to zero reference

Hi all,

I am using the custom BHI160B board with bmm150.

Board is working fine and I am getting the quaternions as output.

Now I want to implement the TARE to reset the quaternions using this code I got from BNO055 library

if(resetflag)
     {
       resetflag = 0;
     qoffset[0] = q[0];       //Stored offsets when sent 's' to serial
     qoffset[1] = -q[1];
     qoffset[2] = -q[2];
     qoffset[3] = -q[3];
     }
     //q[0]...q[3] are live quaternions from fusion
     //qf[0]....qf[3] are tare quaternions using offsets
     qf[0] = q[0] * qoffset[0] - q[1] * qoffset[1] - q[2] * qoffset[2] - q[3] * qoffset[3];      // multiplication matrix
     qf[1] = q[0] * qoffset[1] + q[1] * qoffset[0] + q[2] * qoffset[3] - q[3] * qoffset[2];
     qf[2] = q[0] * qoffset[2] - q[1] * qoffset[3] + q[2] * qoffset[0] + q[3] * qoffset[1];
     qf[3] = q[0] * qoffset[3] + q[1] * qoffset[2] - q[2] * qoffset[1] + q[3] * qoffset[0];     
     //use qf[0..3] to convert to euler angles 
     //-------------------------------------------------------------------------------------------------//

This works sometimes and sometimes messes with the values.

I am converting the quats to Euler angles and found pitch is effecting roll and roll effecting pitch if I tare.
is there something wrong with calculations or process?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.