FlightTask Smoothing: check dt before dividing

This commit is contained in:
ChristophTobler
2018-08-12 09:37:05 -04:00
committed by Daniel Agar
parent 9a23295a40
commit d3d549b8e6
2 changed files with 11 additions and 2 deletions
@@ -146,7 +146,12 @@ void
ManualSmoothingZ::velocitySlewRate(float &vel_sp, const float dt)
{
// limit vertical acceleration
float acc = (vel_sp - _vel_sp_prev) / dt;
float acc = 0.f;
if (dt > FLT_EPSILON) {
acc = (vel_sp - _vel_sp_prev) / dt;
}
float max_acc = (acc < 0.0f) ? -_acc_state_dependent : _acc_state_dependent;
if (fabsf(acc) > fabsf(max_acc)) {