mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 01:18:29 -04:00
AP_Soaring: Detect changes in active parameter/switch position.
This commit is contained in:
parent
fdf7eae01c
commit
2260fda4ec
@ -265,7 +265,7 @@ int16_t GCS_MAVLINK_Plane::vfr_hud_throttle() const
|
|||||||
float GCS_MAVLINK_Plane::vfr_hud_climbrate() const
|
float GCS_MAVLINK_Plane::vfr_hud_climbrate() const
|
||||||
{
|
{
|
||||||
#if SOARING_ENABLED == ENABLED
|
#if SOARING_ENABLED == ENABLED
|
||||||
if (plane.g2.soaring_controller.is_active()) {
|
if (plane.g2.soaring_controller.update_active_state()) {
|
||||||
return plane.g2.soaring_controller.get_vario_reading();
|
return plane.g2.soaring_controller.get_vario_reading();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
*/
|
*/
|
||||||
void Plane::update_soaring() {
|
void Plane::update_soaring() {
|
||||||
|
|
||||||
if (!g2.soaring_controller.is_active()) {
|
// Check if soaring is active. Also sets throttle suppressed
|
||||||
// This also sets the TECS gliding_requested to false.
|
// status on active state changes.
|
||||||
g2.soaring_controller.set_throttle_suppressed(false);
|
if (!g2.soaring_controller.update_active_state()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,6 +355,27 @@ bool SoaringController::is_active() const
|
|||||||
return RC_Channels::get_radio_in(soar_active_ch-1) >= 1400;
|
return RC_Channels::get_radio_in(soar_active_ch-1) >= 1400;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SoaringController::update_active_state()
|
||||||
|
{
|
||||||
|
bool active = is_active();
|
||||||
|
bool state_changed = !(active == _last_update_active);
|
||||||
|
|
||||||
|
if (state_changed) {
|
||||||
|
if (active) {
|
||||||
|
// It's active, but wasn't on the last loop.
|
||||||
|
set_throttle_suppressed(true);
|
||||||
|
} else {
|
||||||
|
// It's not active, but was active on the last loop.
|
||||||
|
set_throttle_suppressed(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_last_update_active = active;
|
||||||
|
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SoaringController::set_throttle_suppressed(bool suppressed)
|
void SoaringController::set_throttle_suppressed(bool suppressed)
|
||||||
{
|
{
|
||||||
_throttle_suppressed = suppressed;
|
_throttle_suppressed = suppressed;
|
||||||
|
@ -52,6 +52,8 @@ class SoaringController {
|
|||||||
float _thermalability;
|
float _thermalability;
|
||||||
float _expected_sink;
|
float _expected_sink;
|
||||||
|
|
||||||
|
bool _last_update_active;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AP_Int8 soar_active;
|
AP_Int8 soar_active;
|
||||||
AP_Int8 soar_active_ch;
|
AP_Int8 soar_active_ch;
|
||||||
@ -112,6 +114,8 @@ public:
|
|||||||
|
|
||||||
bool check_drift(Vector2f prev_wp, Vector2f next_wp);
|
bool check_drift(Vector2f prev_wp, Vector2f next_wp);
|
||||||
|
|
||||||
|
bool update_active_state();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// slow down messages if they are the same. During loiter we could smap the same message. Only show new messages during loiters
|
// slow down messages if they are the same. During loiter we could smap the same message. Only show new messages during loiters
|
||||||
LoiterStatus _cruise_criteria_msg_last;
|
LoiterStatus _cruise_criteria_msg_last;
|
||||||
|
Loading…
Reference in New Issue
Block a user