2017-02-26 19:18:38 -04:00
|
|
|
#include "Plane.h"
|
|
|
|
|
2020-09-23 05:16:45 -03:00
|
|
|
#if HAL_SOARING_ENABLED
|
2018-07-29 19:57:55 -03:00
|
|
|
|
2017-02-26 19:18:38 -04:00
|
|
|
/*
|
|
|
|
* ArduSoar support function
|
|
|
|
*
|
|
|
|
* Peter Braswell, Samuel Tabor, Andrey Kolobov, and Iain Guilliard
|
|
|
|
*/
|
|
|
|
void Plane::update_soaring() {
|
|
|
|
|
2019-07-15 07:27:29 -03:00
|
|
|
// Check if soaring is active. Also sets throttle suppressed
|
|
|
|
// status on active state changes.
|
2020-04-05 08:38:19 -03:00
|
|
|
plane.g2.soaring_controller.update_active_state();
|
|
|
|
|
|
|
|
if (!g2.soaring_controller.is_active()) {
|
2017-02-26 19:18:38 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g2.soaring_controller.update_vario();
|
|
|
|
|
2020-12-30 16:26:08 -04:00
|
|
|
if (control_mode == &mode_thermal) {
|
|
|
|
// We are currently thermalling; suppress throttle and update
|
|
|
|
// the thermal mode.
|
|
|
|
|
2020-09-16 04:46:56 -03:00
|
|
|
// Never use throttle in THERMAL with soaring active.
|
2018-10-18 09:51:21 -03:00
|
|
|
g2.soaring_controller.set_throttle_suppressed(true);
|
2017-02-26 19:18:38 -04:00
|
|
|
|
2020-12-30 16:26:08 -04:00
|
|
|
// Update THERMAL mode soaring logic.
|
|
|
|
mode_thermal.update_soaring();
|
2017-02-26 19:18:38 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-12-30 16:04:30 -04:00
|
|
|
if (control_mode->does_automatic_thermal_switch()) {
|
2020-12-30 16:26:08 -04:00
|
|
|
// We might decide to start thermalling; if we're not under
|
|
|
|
// powered flight then check for thermals and potentially
|
|
|
|
// switch modes.
|
|
|
|
|
|
|
|
// Check for throttle suppression change.
|
|
|
|
if (g2.soaring_controller.suppress_throttle()) {
|
|
|
|
// Throttle is suppressed, perform cruising modes update and check for mode switch.
|
|
|
|
|
|
|
|
// Cruising modes update.
|
|
|
|
g2.soaring_controller.update_cruising();
|
|
|
|
|
|
|
|
// Test for switch into THERMAL mode
|
|
|
|
if (g2.soaring_controller.check_thermal_criteria()) {
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "Soaring: Thermal detected, entering %s", mode_thermal.name());
|
|
|
|
set_mode(mode_thermal, ModeReason::SOARING_THERMAL_DETECTED);
|
|
|
|
}
|
2017-02-26 19:18:38 -04:00
|
|
|
}
|
2020-12-30 16:26:08 -04:00
|
|
|
return;
|
2020-12-30 16:04:30 -04:00
|
|
|
}
|
2020-12-30 16:26:08 -04:00
|
|
|
|
|
|
|
// We are not thermalling and won't start to from this mode. Allow throttle.
|
|
|
|
g2.soaring_controller.set_throttle_suppressed(false);
|
2020-06-26 14:04:19 -03:00
|
|
|
}
|
2019-06-05 15:24:17 -03:00
|
|
|
|
2018-07-29 19:57:55 -03:00
|
|
|
#endif // SOARING_ENABLED
|