@ScrappyMavic
Yes, it's rotated into the horizontal plane. What I did was an adaptation of this article Keeping a Good Attitude: A Quaternion-Based Orientation Filter for IMUs and MARGs
Section 4.2 derives what I call magYaw as a quaternion from the magnetometer data and the pitch/roll quaternion of section 4.1. But, I cheated a little. Whereas section 4.1 derives the pitch/roll quaternion from the accelerometer data I used the pitch/roll from the FC. I don't think that affects the value of magYaw in a material way. What do you think?
Maybe you can read this code
Yes, it's rotated into the horizontal plane. What I did was an adaptation of this article Keeping a Good Attitude: A Quaternion-Based Orientation Filter for IMUs and MARGs
Section 4.2 derives what I call magYaw as a quaternion from the magnetometer data and the pitch/roll quaternion of section 4.1. But, I cheated a little. Whereas section 4.1 derives the pitch/roll quaternion from the accelerometer data I used the pitch/roll from the FC. I don't think that affects the value of magYaw in a material way. What do you think?
Maybe you can read this code
Code:
Quaternion qAcc = Quaternion.fromAngles(pitch, roll, 0.0);
Quaternion x = new Quaternion(0.0, magX, magY, magZ);
Quaternion magXYPlane = qAcc.times(x).times(qAcc.conjugate());
double X = magXYPlane.getX();
double Y = magXYPlane.getY();
return Math.toDegrees(-Math.atan2(Y, X));
Last edited: