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
+13 -12
View File
@@ -123,6 +123,18 @@ void Gyroscope::SensorCorrectionsUpdate(bool force)
}
}
bool Gyroscope::set_offset(const Vector3f &offset)
{
if (Vector3f(_offset - offset).longerThan(0.001f)) {
_offset = offset;
_calibration_count++;
return true;
}
return false;
}
void Gyroscope::set_rotation(Rotation rotation)
{
_rotation_enum = rotation;
@@ -183,19 +195,8 @@ void Gyroscope::ParametersUpdate()
_priority = new_priority;
}
bool calibration_changed = false;
// CAL_GYROx_OFF{X,Y,Z}
const Vector3f offset = GetCalibrationParamsVector3f(SensorString(), "OFF", _calibration_index);
if (Vector3f(_offset - offset).norm_squared() > 0.001f * 0.001f) {
calibration_changed = true;
_offset = offset;
}
if (calibration_changed) {
_calibration_count++;
}
set_offset(GetCalibrationParamsVector3f(SensorString(), "OFF", _calibration_index));
} else {
Reset();