From 09b9ad83dcfa39b596059f597942142eefe6c9f1 Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Sun, 20 Dec 2020 16:42:06 -0500 Subject: [PATCH] AP_Motors: tradheli - add support to determine below mid collective --- libraries/AP_Motors/AP_MotorsHeli.h | 4 ++++ libraries/AP_Motors/AP_MotorsHeli_Dual.cpp | 7 +++++++ libraries/AP_Motors/AP_MotorsHeli_Quad.cpp | 7 +++++++ libraries/AP_Motors/AP_MotorsHeli_Single.cpp | 8 ++++++++ 4 files changed, 26 insertions(+) diff --git a/libraries/AP_Motors/AP_MotorsHeli.h b/libraries/AP_Motors/AP_MotorsHeli.h index b78b7b4a6e8..571d63645b4 100644 --- a/libraries/AP_Motors/AP_MotorsHeli.h +++ b/libraries/AP_Motors/AP_MotorsHeli.h @@ -130,6 +130,9 @@ public: // accessor to get the takeoff collective flag signifying that current collective is greater than collective required to indicate takeoff bool get_takeoff_collective() const { return _heliflags.takeoff_collective; } + // accessor to get the takeoff collective flag signifying that current collective is greater than collective required to indicate takeoff + bool get_below_mid_collective() const { return _heliflags.below_mid_collective; } + // support passing init_targets_on_arming flag to greater code bool init_targets_on_arming() const override { return _heliflags.init_targets_on_arming; } @@ -241,6 +244,7 @@ protected: uint8_t servo_test_running : 1; // true if servo_test is running uint8_t land_complete : 1; // true if aircraft is landed uint8_t takeoff_collective : 1; // true if collective is above 30% between H_COL_MID and H_COL_MAX + uint8_t below_mid_collective : 1; // true if collective is below H_COL_MID } _heliflags; // parameters diff --git a/libraries/AP_Motors/AP_MotorsHeli_Dual.cpp b/libraries/AP_Motors/AP_MotorsHeli_Dual.cpp index 00fa678adcd..41ef4f2bd3e 100644 --- a/libraries/AP_Motors/AP_MotorsHeli_Dual.cpp +++ b/libraries/AP_Motors/AP_MotorsHeli_Dual.cpp @@ -573,6 +573,13 @@ void AP_MotorsHeli_Dual::move_actuators(float roll_out, float pitch_out, float c limit.throttle_lower = true; } + // updates below mid collective flag + if (collective_out <= _collective_mid_pct) { + _heliflags.below_mid_collective = true; + } else { + _heliflags.below_mid_collective = false; + } + // updates takeoff collective flag based on 50% hover collective update_takeoff_collective_flag(collective_out); diff --git a/libraries/AP_Motors/AP_MotorsHeli_Quad.cpp b/libraries/AP_Motors/AP_MotorsHeli_Quad.cpp index 8a3525448bc..dd6bcd0e9f7 100644 --- a/libraries/AP_Motors/AP_MotorsHeli_Quad.cpp +++ b/libraries/AP_Motors/AP_MotorsHeli_Quad.cpp @@ -243,6 +243,13 @@ void AP_MotorsHeli_Quad::move_actuators(float roll_out, float pitch_out, float c limit.throttle_lower = true; } + // updates below mid collective flag + if (collective_out <= _collective_mid_pct) { + _heliflags.below_mid_collective = true; + } else { + _heliflags.below_mid_collective = false; + } + // updates takeoff collective flag based on 50% hover collective update_takeoff_collective_flag(collective_out); diff --git a/libraries/AP_Motors/AP_MotorsHeli_Single.cpp b/libraries/AP_Motors/AP_MotorsHeli_Single.cpp index 6b20212cf1a..c47980752fc 100644 --- a/libraries/AP_Motors/AP_MotorsHeli_Single.cpp +++ b/libraries/AP_Motors/AP_MotorsHeli_Single.cpp @@ -444,6 +444,14 @@ void AP_MotorsHeli_Single::move_actuators(float roll_out, float pitch_out, float if (_heliflags.landing_collective && collective_out < _collective_mid_pct && !_heliflags.in_autorotation) { collective_out = _collective_mid_pct; limit.throttle_lower = true; + + } + + // updates below mid collective flag + if (collective_out <= _collective_mid_pct) { + _heliflags.below_mid_collective = true; + } else { + _heliflags.below_mid_collective = false; } // updates takeoff collective flag based on 50% hover collective