Line data Source code
1 : #include "Plane.h" 2 : 3 : #if HAL_SOARING_ENABLED 4 : 5 : /* 6 : * ArduSoar support function 7 : * 8 : * Peter Braswell, Samuel Tabor, Andrey Kolobov, and Iain Guilliard 9 : */ 10 2736341 : void Plane::update_soaring() { 11 : 12 : // Check if soaring is active. Also sets throttle suppressed 13 : // status on active state changes. 14 2736341 : bool override_disable = mission.get_in_landing_sequence_flag(); 15 : 16 2736341 : plane.g2.soaring_controller.update_active_state(override_disable); 17 : 18 2736341 : if (!g2.soaring_controller.is_active()) { 19 2667574 : return; 20 : } 21 : 22 68767 : g2.soaring_controller.update_vario(); 23 : 24 68767 : if (control_mode == &mode_thermal) { 25 : // We are currently thermalling; suppress throttle and update 26 : // the thermal mode. 27 : 28 : // Never use throttle in THERMAL with soaring active. 29 13618 : g2.soaring_controller.set_throttle_suppressed(true); 30 : 31 : // Update THERMAL mode soaring logic. 32 13618 : mode_thermal.update_soaring(); 33 13618 : return; 34 : } 35 : 36 55149 : if (control_mode->does_automatic_thermal_switch()) { 37 : // We might decide to start thermalling; if we're not under 38 : // powered flight then check for thermals and potentially 39 : // switch modes. 40 : 41 : // Check for throttle suppression change. 42 51738 : if (g2.soaring_controller.suppress_throttle()) { 43 : // Throttle is suppressed, perform cruising modes update and check for mode switch. 44 : 45 : // Cruising modes update. 46 34129 : g2.soaring_controller.update_cruising(); 47 : 48 : // Test for switch into THERMAL mode 49 34129 : if (g2.soaring_controller.check_thermal_criteria()) { 50 1 : gcs().send_text(MAV_SEVERITY_INFO, "Soaring: Thermal detected, entering %s", mode_thermal.name()); 51 1 : set_mode(mode_thermal, ModeReason::SOARING_THERMAL_DETECTED); 52 : } 53 : } 54 51738 : return; 55 : } 56 : 57 : // We are not thermalling and won't start to from this mode. Allow throttle. 58 3411 : g2.soaring_controller.set_throttle_suppressed(false); 59 : } 60 : 61 : #endif // HAL_SOARING_ENABLED