From 8ad195dd51382f4f38c5c8bcfa1a44083733a4db Mon Sep 17 00:00:00 2001 From: Willian Galvani Date: Mon, 23 Sep 2019 13:40:41 -0300 Subject: [PATCH] APMotors_6DOF: Implement motor_is_enabled(), get_motor_angular_factors() and set_reversed(); --- libraries/AP_Motors/AP_Motors6DOF.cpp | 26 ++++++++++++++++++++++++++ libraries/AP_Motors/AP_Motors6DOF.h | 8 ++++++++ 2 files changed, 34 insertions(+) diff --git a/libraries/AP_Motors/AP_Motors6DOF.cpp b/libraries/AP_Motors/AP_Motors6DOF.cpp index e85fb96427..f2588aa236 100644 --- a/libraries/AP_Motors/AP_Motors6DOF.cpp +++ b/libraries/AP_Motors/AP_Motors6DOF.cpp @@ -551,3 +551,29 @@ void AP_Motors6DOF::output_armed_stabilizing_vectored_6dof() } } } + +Vector3f AP_Motors6DOF::get_motor_angular_factors(int motor_number) { + if (motor_number < 0 || motor_number >= AP_MOTORS_MAX_NUM_MOTORS) { + return Vector3f(0,0,0); + } + return Vector3f(_roll_factor[motor_number], _pitch_factor[motor_number], _yaw_factor[motor_number]); +} + +bool AP_Motors6DOF::motor_is_enabled(int motor_number) { + if (motor_number < 0 || motor_number >= AP_MOTORS_MAX_NUM_MOTORS) { + return false; + } + return motor_enabled[motor_number]; +} + +bool AP_Motors6DOF::set_reversed(int motor_number, bool reversed) { + if (motor_number < 0 || motor_number >= AP_MOTORS_MAX_NUM_MOTORS) { + return false; + } + if (reversed) { + _motor_reverse[motor_number].set_and_save(-1); + } else { + _motor_reverse[motor_number].set_and_save(1); + } + return true; +} diff --git a/libraries/AP_Motors/AP_Motors6DOF.h b/libraries/AP_Motors/AP_Motors6DOF.h index 108e1dc896..0eca46808f 100644 --- a/libraries/AP_Motors/AP_Motors6DOF.h +++ b/libraries/AP_Motors/AP_Motors6DOF.h @@ -41,6 +41,14 @@ public: // output_to_motors - sends minimum values out to the motors void output_to_motors() override; + // returns a vector with roll, pitch, and yaw contributions + Vector3f get_motor_angular_factors(int motor_number); + + // returns true if motor is enabled + bool motor_is_enabled(int motor_number); + + bool set_reversed(int motor_number, bool reversed); + // var_info for holding Parameter information static const struct AP_Param::GroupInfo var_info[];