EKF: Rework quaternion yaw reset.

Use a new method that preserves the roll and pitch information and adds the uncertainty for yaw only.
Ensure that correlation information to non-quaternion states is removed when a reset occurs to prevent fusion of subsequent observations (e.g. GPS) causing incorrect yaw.
This commit is contained in:
Paul Riseborough
2019-01-31 09:53:57 -05:00
committed by Daniel Agar
parent fc2a089823
commit ef5a87c1d4
3 changed files with 13 additions and 30 deletions
+2 -8
View File
@@ -385,14 +385,11 @@ bool Ekf::resetGpsAntYaw()
delta_ang_error(1) = scalar * q_error(2);
delta_ang_error(2) = scalar * q_error(3);
// calculate the variance for the rotation estimate expressed as a rotation vector
// this will be used later to reset the quaternion state covariances
Vector3f angle_err_var_vec = calcRotVecVariances();
// update the quaternion state estimates and corresponding covariances only if the change in angle has been large or the yaw is not yet aligned
if (delta_ang_error.norm() > math::radians(15.0f) || !_control_status.flags.yaw_align) {
// update quaternion states
_state.quat_nominal = quat_after_reset;
uncorrelateQuatStates();
// record the state change
_state_reset_status.quat_change = q_error;
@@ -406,10 +403,7 @@ bool Ekf::resetGpsAntYaw()
}
// update the yaw angle variance using the variance of the measurement
angle_err_var_vec(2) = sq(fmaxf(_params.mag_heading_noise, 1.0e-2f));
// reset the quaternion covariances using the rotation vector variances
initialiseQuatCovariances(angle_err_var_vec);
increaseQuatYawErrVariance(sq(fmaxf(_params.mag_heading_noise, 1.0e-2f)));
// add the reset amount to the output observer buffered data
for (uint8_t i = 0; i < _output_buffer.get_length(); i++) {