From 2a01f234476766f5c6b70d7134805b4d163c109b Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Wed, 4 Mar 2020 15:05:13 +0900 Subject: [PATCH] Plane: quadplane's throttle mix uses filtered accelerations --- ArduPlane/quadplane.cpp | 9 ++++++--- ArduPlane/quadplane.h | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ArduPlane/quadplane.cpp b/ArduPlane/quadplane.cpp index 1a3f7c5b33333..c9ae6e097f2dd 100644 --- a/ArduPlane/quadplane.cpp +++ b/ArduPlane/quadplane.cpp @@ -3160,6 +3160,11 @@ float QuadPlane::stopping_distance(void) void QuadPlane::update_throttle_mix(void) { + // update filtered acceleration + Vector3f accel_ef = ahrs.get_accel_ef_blended(); + accel_ef.z += GRAVITY_MSS; + throttle_mix_accel_ef_filter.apply(accel_ef, plane.scheduler.get_loop_period_s()); + // transition will directly manage the mix if (in_transition()) { return; @@ -3190,9 +3195,7 @@ void QuadPlane::update_throttle_mix(void) bool large_angle_error = (angle_error > LAND_CHECK_ANGLE_ERROR_DEG); // check for large acceleration - falling or high turbulence - Vector3f accel_ef = plane.ahrs.get_accel_ef_blended(); - accel_ef.z += GRAVITY_MSS; - bool accel_moving = (accel_ef.length() > LAND_CHECK_ACCEL_MOVING); + bool accel_moving = (throttle_mix_accel_ef_filter.get().length() > LAND_CHECK_ACCEL_MOVING); // check for requested decent bool descent_not_demanded = pos_control->get_desired_velocity().z >= 0.0f; diff --git a/ArduPlane/quadplane.h b/ArduPlane/quadplane.h index c283da4b5a1cb..aa4768118a6f1 100644 --- a/ArduPlane/quadplane.h +++ b/ArduPlane/quadplane.h @@ -388,6 +388,9 @@ class QuadPlane float vpos_start_m; } landing_detect; + // throttle mix acceleration filter + LowPassFilterVector3f throttle_mix_accel_ef_filter = LowPassFilterVector3f(1.0f); + // time we last set the loiter target uint32_t last_loiter_ms;