Skip to content

Commit

Permalink
AP_InertialNav: freeze horiz_vel when !velned_ok
Browse files Browse the repository at this point in the history
This addresses concerns about brief failures of get_velocity_NED causing
abrupt changes to the horizonatl velocity estimate.
  • Loading branch information
robertlong13 committed Nov 6, 2023
1 parent 6d4abd8 commit fe9dde3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions libraries/AP_InertialNav/AP_InertialNav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@ void AP_InertialNav::update(bool high_vibes)

// get the velocity relative to the local earth frame
Vector3f velNED;

const bool velned_ok = _ahrs_ekf.get_velocity_NED(velNED);
/*
during high vibration events use vertical position change. If
get_velocity_NED() fails we use a zero horizontal velocity
*/
if (velned_ok) {
_velocity_cm = -velNED * 100; // convert from m/s in NED to cm/s in NEU
}
// During high vibration events, or failure of get_velocity_NED, use the
// fallback vertical velocity estimate. For get_velocity_NED failure, freeze
// the horizontal velocity at the last good value.
if (!velned_ok || high_vibes) {
float rate_z;
if (_ahrs_ekf.get_vert_pos_rate_D(rate_z)) {
velNED.z = rate_z;
_velocity_cm.z = -rate_z * 100; // convert from m/s in NED to cm/s in NEU
}
}
_velocity_cm = velNED * 100; // convert to cm/s
_velocity_cm.z = -_velocity_cm.z; // convert from NED to NEU
}

/**
Expand Down

0 comments on commit fe9dde3

Please sign in to comment.