From a152ad70a914159231aa4b3e4569d0a5ec5b884d Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 31 Aug 2021 13:15:18 +1000 Subject: [PATCH] AP_Motors: use structures to save flash when initialising motors (raw motors) --- libraries/AP_Motors/AP_MotorsMatrix.cpp | 142 +++++++++++++++--------- libraries/AP_Motors/AP_MotorsMatrix.h | 16 ++- 2 files changed, 102 insertions(+), 56 deletions(-) diff --git a/libraries/AP_Motors/AP_MotorsMatrix.cpp b/libraries/AP_Motors/AP_MotorsMatrix.cpp index 3ec1e6fdec..6db11e7dc5 100644 --- a/libraries/AP_Motors/AP_MotorsMatrix.cpp +++ b/libraries/AP_Motors/AP_MotorsMatrix.cpp @@ -568,6 +568,13 @@ void AP_MotorsMatrix::add_motors(T *motors, uint8_t num_motors) add_motor(motor.motor_num, motor.angle_degrees, motor.yaw_factor, motor.testing_order); } } +void AP_MotorsMatrix::add_motors_raw(const struct MotorDefRaw *motors, uint8_t num_motors) +{ + for (uint8_t i=0; i void add_motors(T *motor, uint8_t num_motors); + // structure used for initialising motors that add have separate + // roll/pitch/yaw factors. Note that this does *not* include + // the final parameter for the add_motor_raw call - throttle + // factor as that is only used in the scripting binding, not in + // the static motors at the moment. + struct MotorDefRaw { + int8_t motor_num; + float roll_fac; + float pitch_fac; + float yaw_fac; + uint8_t testing_order; + }; + void add_motors_raw(const struct MotorDefRaw *motors, uint8_t num_motors); + protected: // output - sends commands to the motors void output_armed_stabilizing() override; @@ -148,8 +162,6 @@ protected: const char* _frame_class_string = ""; // string representation of frame class const char* _frame_type_string = ""; // string representation of frame type - private: static AP_MotorsMatrix *_singleton; - };