Magnetic calibration model does not match MATLAB and others
Closed this issue · 6 comments
Hello.
I spent a lot of time to setup and run up that code. Unfortunately with no success.
My goal is to calculate heading by using MAG and ACC. I used FusionCalibrationMagnetic() in that purpose.
In order to calibrate MAG and ACC i tied to use two different ways: 1. MagMaster app and 2. Magneto. These applications generate transformation matrix (soft iron) and bias (hard iron offset). Then I used outputs from these applications in your code (check out Annex1)
So
I assume that FusionCalibrationMagnetic() does not work properly with your calibration model (mc = Smu - h). Fortunately, if use regular model (mc = S(mu - h)) it works better but actually not stable.
mc is the calibrated magnetometer measurement and return value
mu is the uncalibrated magnetometer measurement and uncalibrated argument
S is the soft iron matrix and softIronMatrix argument
h is the hard iron offset vector and hardIronOffset argument
So, I assumed that code does not work properly (include yaw, roll, pitch). Visualization by using processing confirm my assumption.
My setup: teensy board and different IMUs(9250, Gy86, Gy91 and etc)
It would be great to see/read applicable instruction how to it use.
Annex1 (example of my code with soft and hard iron):
//Accelerometer transformation matrix
const FusionMatrix accelerometerMisalignment = {0.997900, -0.013244, -0.000926, -0.013244, 0.998071, -0.002810, -0.000926, -0.002810, 0.972633};
const FusionVector accelerometerSensitivity = {1.0, 1.0, 1.0};
const FusionVector accelerometerOffset = {-0.001079, 0.009427, -0.020567}; //Bias
//Magnetometer transformation matrix
const FusionMatrix softIronMatrix = {0.076813, 0.000005, -0.000037, 0.000005, 0.073755, -0.002360, -0.000037, -0.002360, 0.084221};
const FusionVector hardIronOffset = {64.808407, 277.759814, -536.878619}; //Bias
The function FusionCalibrationMagnetic
implements the expression mc = Smu - h, as described in the README. This implementation is as follows (see line 37).
static inline FusionVector FusionCalibrationMagnetic(const FusionVector uncalibrated, const FusionMatrix softIronMatrix, const FusionVector hardIronOffset) {
return FusionVectorSubtract(FusionMatrixMultiplyVector(softIronMatrix, uncalibrated), hardIronOffset);
}
If you believe that the code does not work then please demonstrate this in a way that others can replaciate.
Both
It is also my understanding that
If we were to instead use
That said, conventions are important. If there is a general consensus for
The magnetic calibration model has been updated to
Thy for update!
@Overff how did you get the accelerometer transformation matrices? I couldn't find MagMaster, but both seem for the Magnetometer ?