diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index 97056f0ddf..5698e6087b 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -561,6 +561,9 @@ private: // with STICK_MIXING=0 bool auto_navigation_mode:1; + // this allows certain flight modes to mix RC input with throttle depending on airspeed_nudge_cm + bool throttle_allows_nudging:1; + // this controls throttle suppression in auto modes bool throttle_suppressed; diff --git a/ArduPlane/navigation.cpp b/ArduPlane/navigation.cpp index 55fca1f519..f9f1c44147 100644 --- a/ArduPlane/navigation.cpp +++ b/ArduPlane/navigation.cpp @@ -135,7 +135,7 @@ void Plane::calc_airspeed_errors() } // Bump up the target airspeed based on throttle nudging - if (control_mode >= AUTO && airspeed_nudge_cm > 0) { + if (throttle_allows_nudging && airspeed_nudge_cm > 0) { target_airspeed_cm += airspeed_nudge_cm; } diff --git a/ArduPlane/servos.cpp b/ArduPlane/servos.cpp index 46cf5dcf25..1e19c71c1d 100644 --- a/ArduPlane/servos.cpp +++ b/ArduPlane/servos.cpp @@ -581,7 +581,7 @@ void Plane::set_servos(void) // setup flap outputs set_servos_flaps(); - if (control_mode >= FLY_BY_WIRE_B || + if (auto_throttle_mode || quadplane.in_assisted_flight() || quadplane.in_vtol_mode()) { /* only do throttle slew limiting in modes where throttle diff --git a/ArduPlane/system.cpp b/ArduPlane/system.cpp index fb91c9afee..0f410a3ac3 100644 --- a/ArduPlane/system.cpp +++ b/ArduPlane/system.cpp @@ -327,6 +327,7 @@ void Plane::set_mode(enum FlightMode mode, mode_reason_t reason) switch(control_mode) { case INITIALISING: + throttle_allows_nudging = true; auto_throttle_mode = true; auto_navigation_mode = false; break; @@ -335,17 +336,20 @@ void Plane::set_mode(enum FlightMode mode, mode_reason_t reason) case STABILIZE: case TRAINING: case FLY_BY_WIRE_A: + throttle_allows_nudging = false; auto_throttle_mode = false; auto_navigation_mode = false; break; case AUTOTUNE: + throttle_allows_nudging = false; auto_throttle_mode = false; auto_navigation_mode = false; autotune_start(); break; case ACRO: + throttle_allows_nudging = false; auto_throttle_mode = false; auto_navigation_mode = false; acro_state.locked_roll = false; @@ -353,6 +357,7 @@ void Plane::set_mode(enum FlightMode mode, mode_reason_t reason) break; case CRUISE: + throttle_allows_nudging = false; auto_throttle_mode = true; auto_navigation_mode = false; cruise_state.locked_heading = false; @@ -365,6 +370,7 @@ void Plane::set_mode(enum FlightMode mode, mode_reason_t reason) break; case FLY_BY_WIRE_B: + throttle_allows_nudging = false; auto_throttle_mode = true; auto_navigation_mode = false; @@ -376,12 +382,14 @@ void Plane::set_mode(enum FlightMode mode, mode_reason_t reason) case CIRCLE: // the altitude to circle at is taken from the current altitude + throttle_allows_nudging = false; auto_throttle_mode = true; auto_navigation_mode = true; next_WP_loc.alt = current_loc.alt; break; case AUTO: + throttle_allows_nudging = true; auto_throttle_mode = true; auto_navigation_mode = true; if (quadplane.available() && quadplane.enable == 2) { @@ -397,6 +405,7 @@ void Plane::set_mode(enum FlightMode mode, mode_reason_t reason) break; case RTL: + throttle_allows_nudging = true; auto_throttle_mode = true; auto_navigation_mode = true; prev_WP_loc = current_loc; @@ -404,6 +413,7 @@ void Plane::set_mode(enum FlightMode mode, mode_reason_t reason) break; case LOITER: + throttle_allows_nudging = true; auto_throttle_mode = true; auto_navigation_mode = true; do_loiter_at_location(); @@ -418,6 +428,7 @@ void Plane::set_mode(enum FlightMode mode, mode_reason_t reason) case AVOID_ADSB: case GUIDED: + throttle_allows_nudging = true; auto_throttle_mode = true; auto_navigation_mode = true; guided_throttle_passthru = false; @@ -434,6 +445,7 @@ void Plane::set_mode(enum FlightMode mode, mode_reason_t reason) case QLOITER: case QLAND: case QRTL: + throttle_allows_nudging = true; auto_navigation_mode = false; if (!quadplane.init_mode()) { control_mode = previous_mode;