Absolute rotation vector vs Magnetic Field Strength Vector of BNO085


I'm using the Adafruit BNO085 IMU.

I'm trying to get the absolute orientation. First I was converted the magnetic field strength vector to a degree (heading) using this formula.

heading = atan2(y, x) * 180 / M_PI;

I also realized that it has the option to produce an absolute orientation vector using fusion sensor (magnetometer, gyro, and accelerometer) in Quaternion.

I changed that to get euler's coordinates.

Now my issue is that these numbers are not the same. Like they're more or less 90 degrees apart. I guess I'm understanding something incorrectly. Which one should I be using to get the correct heading and what do these actually represent if my logic is already flawed?


The atan2(y,x) equation results in heading = 0 degrees when the sensor is level, with Z up and the X axis pointing magnetic North. Use atan2(x,y) for Y North. The direction of rotation will change.

Check the BNO085 data sheet for the definition of the absolute orientation vector.

Oh! Yes, I realized that when I did atan2(y,x) magnetic north was in the x direction. And the absolute orientation was near the y direction (as I said previously more or less 90). Maybe the rest of the difference is due to the sensor fusion?

This is what the datasheet says, which is too general I guess?
"The rotation vector provides an orientation output that is expressed as a quaternion referenced to magnetic north and gravity. It is produced by fusing the outputs of the accelerometer, gyroscope and magnetometer. The rotation vector is the most accurate orientation estimate available. The magnetometer provides correction in yaw to reduce drift and the gyroscope enables the most responsive performance. "

Figure 4.2 of the BNO085 data sheet shows that Y pointing magnetic North, X east and Z up (ENU convention) will give you heading = 0 degrees for the fusion calculation. Other standard orientations can be selected programmatically.

But unless the magnetometer is correctly calibrated, calculated orientations won't be accurate and unfortunately, the BNO0xx automatic calibration does not work well.