Skip to content

Commit

Permalink
AP_InertialNav: add fallback vertical velocity
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlong13 committed Oct 25, 2023
1 parent 62af92e commit bf90399
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
10 changes: 7 additions & 3 deletions libraries/AP_AHRS/AP_AHRS_DCM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1205,10 +1205,14 @@ Vector2f AP_AHRS_DCM::groundspeed_vector(void)
bool AP_AHRS_DCM::get_vert_pos_rate_D(float &velocity) const
{
Vector3f velned;
if (!get_velocity_NED(velned)) {
return false;
if (get_velocity_NED(velned)) {
velocity = velned.z;
}
else
{
velocity = -AP::baro().get_climb_rate();
}
velocity = velned.z;

return true;
}

Expand Down
20 changes: 11 additions & 9 deletions libraries/AP_InertialNav/AP_InertialNav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ void AP_InertialNav::update(bool high_vibes)

// get the velocity relative to the local earth frame
Vector3f velNED;
if (_ahrs_ekf.get_velocity_NED(velNED)) {
// during high vibration events use vertical position change
if (high_vibes) {
float rate_z;
if (_ahrs_ekf.get_vert_pos_rate_D(rate_z)) {
velNED.z = rate_z;
}
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 || high_vibes) {
float rate_z;
if (_ahrs_ekf.get_vert_pos_rate_D(rate_z)) {
velNED.z = rate_z;
}
_velocity_cm = velNED * 100; // convert to cm/s
_velocity_cm.z = -_velocity_cm.z; // convert from NED to 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 bf90399

Please sign in to comment.