save learned mag bias per sensor (Multi-EKF support)

- handle saving the mag bias per sensor (across all estimator instances using that mag) in sensors/vehicle_magnetometer
 - this is now saving back to the actual mag calibration CAL_MAGn_OFF{X,Y,Z}
 - ekf2 reset mag mag bias on any magnetometer or calibration change
 - use Kalman filter scheme to update stored mag bias parameters using all available bias estimates for that sensor

Co-authored-by: Paul Riseborough <gncsolns@gmail.com>
This commit is contained in:
Daniel Agar
2021-01-07 09:54:13 -05:00
committed by GitHub
co-authored by Paul Riseborough
parent 537ee5b19b
commit 88f8da27ef
17 changed files with 328 additions and 308 deletions
-87
View File
@@ -428,17 +428,6 @@ PARAM_DEFINE_FLOAT(EKF2_BETA_GATE, 5.0f);
*/
PARAM_DEFINE_FLOAT(EKF2_BETA_NOISE, 0.3f);
/**
* Magnetic declination
*
* @group EKF2
* @volatile
* @category system
* @unit deg
* @decimal 1
*/
PARAM_DEFINE_FLOAT(EKF2_MAG_DECL, 0);
/**
* Gate size for magnetic heading fusion
*
@@ -1049,82 +1038,6 @@ PARAM_DEFINE_FLOAT(EKF2_ANGERR_INIT, 0.1f);
*/
PARAM_DEFINE_FLOAT(EKF2_RNG_PITCH, 0.0f);
/**
* Learned value of magnetometer X axis bias.
* This is the amount of X-axis magnetometer bias learned by the EKF and saved from the last flight. It must be set to zero if the ground based magnetometer calibration is repeated.
*
* @group EKF2
* @min -0.5
* @max 0.5
* @reboot_required true
* @volatile
* @category system
* @unit gauss
* @decimal 3
*/
PARAM_DEFINE_FLOAT(EKF2_MAGBIAS_X, 0.0f);
/**
* Learned value of magnetometer Y axis bias.
* This is the amount of Y-axis magnetometer bias learned by the EKF and saved from the last flight. It must be set to zero if the ground based magnetometer calibration is repeated.
*
* @group EKF2
* @min -0.5
* @max 0.5
* @reboot_required true
* @volatile
* @category system
* @unit gauss
* @decimal 3
*/
PARAM_DEFINE_FLOAT(EKF2_MAGBIAS_Y, 0.0f);
/**
* Learned value of magnetometer Z axis bias.
* This is the amount of Z-axis magnetometer bias learned by the EKF and saved from the last flight. It must be set to zero if the ground based magnetometer calibration is repeated.
*
* @group EKF2
* @min -0.5
* @max 0.5
* @reboot_required true
* @volatile
* @category system
* @unit gauss
* @decimal 3
*/
PARAM_DEFINE_FLOAT(EKF2_MAGBIAS_Z, 0.0f);
/**
* ID of Magnetometer the learned bias is for.
*
* @group EKF2
* @reboot_required true
* @category system
*/
PARAM_DEFINE_INT32(EKF2_MAGBIAS_ID, 0);
/**
* State variance assumed for magnetometer bias storage.
* This is a reference variance used to calculate the fraction of learned magnetometer bias that will be used to update the stored value. Smaller values will make the stored bias data adjust more slowly from flight to flight. Larger values will make it adjust faster.
*
* @group EKF2
* @reboot_required true
* @unit gauss^2
* @decimal 8
*/
PARAM_DEFINE_FLOAT(EKF2_MAGB_VREF, 2.5E-7f);
/**
* Maximum fraction of learned mag bias saved at each disarm.
* Smaller values make the saved mag bias learn slower from flight to flight. Larger values make it learn faster. Must be > 0.0 and <= 1.0.
*
* @group EKF2
* @min 0.0
* @max 1.0
* @decimal 2
*/
PARAM_DEFINE_FLOAT(EKF2_MAGB_K, 0.2f);
/**
* Range sensor aid.
*