From c504e2db04f2dfc4f6d41afbfef1f7c81d8aa6e3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 12 Dec 2020 15:45:57 +1100 Subject: [PATCH] AP_Motors: added disable_yaw_torque() method this is used for tilt-vectored quadplanes to use only vectoring for yaw control. This avoids some nasty transition issues --- libraries/AP_Motors/AP_MotorsMatrix.cpp | 11 +++++++++++ libraries/AP_Motors/AP_MotorsMatrix.h | 4 ++++ libraries/AP_Motors/AP_MotorsMulticopter.h | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/libraries/AP_Motors/AP_MotorsMatrix.cpp b/libraries/AP_Motors/AP_MotorsMatrix.cpp index 5c789282ca..0a7241e6c6 100644 --- a/libraries/AP_Motors/AP_MotorsMatrix.cpp +++ b/libraries/AP_Motors/AP_MotorsMatrix.cpp @@ -969,3 +969,14 @@ void AP_MotorsMatrix::thrust_compensation(void) _thrust_compensation_callback(_thrust_rpyt_out, AP_MOTORS_MAX_NUM_MOTORS); } } + +/* + disable the use of motor torque to control yaw. Used when an + external mechanism such as vectoring is used for yaw control +*/ +void AP_MotorsMatrix::disable_yaw_torque(void) +{ + for (uint8_t i = 0; i < AP_MOTORS_MAX_NUM_MOTORS; i++) { + _yaw_factor[i] = 0; + } +} diff --git a/libraries/AP_Motors/AP_MotorsMatrix.h b/libraries/AP_Motors/AP_MotorsMatrix.h index b81f8ff4ca..127483e47e 100644 --- a/libraries/AP_Motors/AP_MotorsMatrix.h +++ b/libraries/AP_Motors/AP_MotorsMatrix.h @@ -55,6 +55,10 @@ public: // using copter motors for forward flight float get_roll_factor(uint8_t i) override { return _roll_factor[i]; } + // disable the use of motor torque to control yaw. Used when an external mechanism such + // as vectoring is used for yaw control + void disable_yaw_torque(void) override; + protected: // output - sends commands to the motors void output_armed_stabilizing() override; diff --git a/libraries/AP_Motors/AP_MotorsMulticopter.h b/libraries/AP_Motors/AP_MotorsMulticopter.h index 6c5f4373c3..59c4402b5e 100644 --- a/libraries/AP_Motors/AP_MotorsMulticopter.h +++ b/libraries/AP_Motors/AP_MotorsMulticopter.h @@ -96,6 +96,10 @@ public: _thrust_compensation_callback = callback; } + // disable the use of motor torque to control yaw. Used when an external mechanism such + // as vectoring is used for yaw control + virtual void disable_yaw_torque(void) {} + // var_info for holding Parameter information static const struct AP_Param::GroupInfo var_info[];