A tool for calibrating compass from a flight log. Measured mag field from the log is compared to the expected field for the given location and attitude. A number of fits are done with varying degrees of freedom to allow the user to select the best.
This tool calculates the calibration parameters these are (first compass):
COMPASS_OFS_X:
COMPASS_OFS_Y:
COMPASS_OFS_Z:
COMPASS_SCALE:
COMPASS_DIA_X:
COMPASS_DIA_Y:
COMPASS_DIA_Z:
COMPASS_ODI_X:
COMPASS_ODI_Y:
COMPASS_ODI_Z:
These form the symmetrical iron correction matrix:
COMPASS_MOT_X:
COMPASS_MOT_Y:
COMPASS_MOT_Z:
Raw readings from the compass are given by:
Motor calibration values from either battery current or throttle level are given by:
The calibration is then applied:
This tool assembles the measured and expected earth field into a matrix in the form
Is solved resulting in the value of
This can also be written as:
At each logged compass data point the vehicles attitude is interpolated from the selected attitude source. This is then used to calculate the expected earth field in body frame.
x, y and z axis measurements:
x, y and z axis expected:
Motor calibration value, either battery current or throttle is also interpolated:
The matrices for
If only the offsets are being fitted the formulation is as follows.
Solution array
Matrix
Array
If offsets and scale are being fitted the formulation is as follows.
Solution array
The offsets are extracted by removing the scale factor given by the last item in the array.
Matrix
Array
If offsets and iron matrix are being fitted the formulation is as follows.
The values
The iron matrix is then normalized to give a value for the scale.
Matrix
As before the array
Motor calibration is added by extending the
Each data point is assigned a weighting based on the the vehicles attitude. Attitudes that occur less frequently get a larger weighting that those which are seen frequently.
The equation then becomes:
To restore the standard