I have been using BNO080 module to compute vehicle heading. I would like to know the formulae that works for the tilt compensation when the chip is oriented in any way i.e. facing up and down (i.e. -ve or positive Z accelaration).Can I get help on how I can establish this? Any formulae will be helpful.
Currently I use magnetometer and accelometer values to do this using below formulae. It works for +ve Z accel but does not work for -ve Z accel.
pitch = asin((-1) * accXnorm);
roll = asinf (accYnorm/cos(pitch));
float xh = (magX * cos(pitch)) + (magZ * sin(pitch));
float yh = magX * sin(roll) * sin(pitch) + magY * cos(roll) - magZ * sin(roll) * cos(pitch);
tiltHeading = ((180 * atan2(yh, xh))/ M_PI);