/* We want to suppress the throttle if we think we are on the ground and in an autopilot controlled throttle mode. Disable throttle if following conditions are met: * 1 - We are in Circle mode (which we use for short term failsafe), or in FBW-B or higher * AND * 2 - Our reported altitude is within 10 meters of the home altitude. * 3 - Our reported speed is under 5 meters per second. * 4 - We are not performing a takeoff in Auto mode or takeoff speed/accel not yet reached * OR * 5 - Home location is not set */ bool Plane::suppress_throttle(void) { if (!throttle_suppressed) { // we've previously met a condition for unsupressing the throttle return false; } if (!auto_throttle_mode) { // the user controls the throttle throttle_suppressed = false; return false; } if (control_mode==AUTO && g.auto_fbw_steer) { // user has throttle control return false; } if (control_mode==AUTO && auto_state.takeoff_complete == false) { if (auto_takeoff_check()) { // we're in auto takeoff throttle_suppressed = false; return false; } // keep throttle suppressed return true; } if (relative_altitude_abs_cm() >= 1000) { // we're more than 10m from the home altitude throttle_suppressed = false; gcs_send_text_fmt(PSTR("Throttle unsuppressed - altitude %.2f"), (double)(relative_altitude_abs_cm()*0.01f)); return false; } if (gps.status() >= AP_GPS::GPS_OK_FIX_2D && gps.ground_speed() >= 5) { // if we have an airspeed sensor, then check it too, and // require 5m/s. This prevents throttle up due to spiky GPS // groundspeed with bad GPS reception if ((!ahrs.airspeed_sensor_enabled()) || airspeed.get_airspeed() >= 5) { // we're moving at more than 5 m/s gcs_send_text_fmt(PSTR("Throttle unsuppressed - speed %.2f airspeed %.2f"), (double)gps.ground_speed(), (double)airspeed.get_airspeed()); throttle_suppressed = false; return false; } } // throttle remains suppressed return true; }
/* We want to suppress the throttle if we think we are on the ground and in an autopilot controlled throttle mode. Disable throttle if following conditions are met: * 1 - We are in Circle mode (which we use for short term failsafe), or in FBW-B or higher * AND * 2 - Our reported altitude is within 10 meters of the home altitude. * 3 - Our reported speed is under 5 meters per second. * 4 - We are not performing a takeoff in Auto mode or takeoff speed/accel not yet reached * OR * 5 - Home location is not set * OR * 6- Landing does not want to allow throttle */ bool Plane::suppress_throttle(void) { #if PARACHUTE == ENABLED if (auto_throttle_mode && parachute.release_initiated()) { // throttle always suppressed in auto-throttle modes after parachute release initiated throttle_suppressed = true; return true; } #endif if (landing.is_throttle_suppressed()) { return true; } if (!throttle_suppressed) { // we've previously met a condition for unsupressing the throttle return false; } if (!auto_throttle_mode) { // the user controls the throttle throttle_suppressed = false; return false; } if (control_mode==AUTO && g.auto_fbw_steer == 42) { // user has throttle control return false; } bool gps_movement = (gps.status() >= AP_GPS::GPS_OK_FIX_2D && gps.ground_speed() >= 5); if (control_mode==AUTO && auto_state.takeoff_complete == false) { uint32_t launch_duration_ms = ((int32_t)g.takeoff_throttle_delay)*100 + 2000; if (is_flying() && millis() - started_flying_ms > MAX(launch_duration_ms, 5000U) && // been flying >5s in any mode adjusted_relative_altitude_cm() > 500 && // are >5m above AGL/home labs(ahrs.pitch_sensor) < 3000 && // not high pitch, which happens when held before launch gps_movement) { // definite gps movement // we're already flying, do not suppress the throttle. We can get // stuck in this condition if we reset a mission and cmd 1 is takeoff // but we're currently flying around below the takeoff altitude throttle_suppressed = false; return false; } if (auto_takeoff_check()) { // we're in auto takeoff throttle_suppressed = false; auto_state.baro_takeoff_alt = barometer.get_altitude(); return false; } // keep throttle suppressed return true; } if (fabsf(relative_altitude) >= 10.0f) { // we're more than 10m from the home altitude throttle_suppressed = false; return false; } if (gps_movement) { // if we have an airspeed sensor, then check it too, and // require 5m/s. This prevents throttle up due to spiky GPS // groundspeed with bad GPS reception if ((!ahrs.airspeed_sensor_enabled()) || airspeed.get_airspeed() >= 5) { // we're moving at more than 5 m/s throttle_suppressed = false; return false; } } if (quadplane.is_flying()) { throttle_suppressed = false; return false; } // throttle remains suppressed return true; }