commander: reset learned ekf2 mag biases when performing a mag cal

The learned ekf2 mag bias values are invalidated when the sensor calibration is updated and must be reset.
This commit is contained in:
Paul Riseborough 2017-03-30 09:23:15 +11:00 committed by Lorenz Meier
parent 6474922224
commit 6473f1458f
1 changed files with 18 additions and 0 deletions

View File

@ -113,6 +113,24 @@ int do_mag_calibration(orb_advert_t *mavlink_log_pub)
char str[30];
// reset the learned EKF mag in-flight bias offsets which have been learned for the previous
// sensor calibration and will be invalidated by a new sensor calibration
(void)sprintf(str, "EKF2_MAGBIAS_X");
result = param_set(param_find(str), &mscale_null.x_offset);
if (result != PX4_OK) {
PX4_ERR("unable to reset %s", str);
}
(void)sprintf(str, "EKF2_MAGBIAS_Y");
result = param_set(param_find(str), &mscale_null.y_offset);
if (result != PX4_OK) {
PX4_ERR("unable to reset %s", str);
}
(void)sprintf(str, "EKF2_MAGBIAS_Z");
result = param_set(param_find(str), &mscale_null.z_offset);
if (result != PX4_OK) {
PX4_ERR("unable to reset %s", str);
}
for (size_t i = 0; i < max_mags; i++) {
device_ids[i] = 0; // signals no mag
}