From fdac66878251bb1839efbcf4aa9fff24cedde5c0 Mon Sep 17 00:00:00 2001 From: Tatsuya Yamaguchi Date: Fri, 19 May 2023 11:56:52 +0900 Subject: [PATCH] Copter: implement is_landing and is_taking_off for use by lua --- ArduCopter/Copter.cpp | 12 ++++++++++++ ArduCopter/Copter.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/ArduCopter/Copter.cpp b/ArduCopter/Copter.cpp index 170ed3d649..dbb3357f5c 100644 --- a/ArduCopter/Copter.cpp +++ b/ArduCopter/Copter.cpp @@ -443,6 +443,18 @@ bool Copter::has_ekf_failsafed() const return failsafe.ekf; } +// returns true if vehicle is landing. Only used by Lua scripts +bool Copter::is_landing() const +{ + return flightmode->is_landing(); +} + +// returns true if vehicle is taking off. Only used by Lua scripts +bool Copter::is_taking_off() const +{ + return flightmode->is_taking_off(); +} + #endif // AP_SCRIPTING_ENABLED bool Copter::current_mode_requires_mission() const diff --git a/ArduCopter/Copter.h b/ArduCopter/Copter.h index c8614c4faf..38dfe29b50 100644 --- a/ArduCopter/Copter.h +++ b/ArduCopter/Copter.h @@ -679,6 +679,8 @@ private: // lua scripts use this to retrieve EKF failsafe state // returns true if the EKF failsafe has triggered bool has_ekf_failsafed() const override; + bool is_landing() const override; + bool is_taking_off() const override; #endif // AP_SCRIPTING_ENABLED void rc_loop(); void throttle_loop();