From 20889ff8a956ce7cae6ab512b06a0023715075d8 Mon Sep 17 00:00:00 2001 From: Jacob Walser Date: Mon, 10 Jul 2017 17:25:45 -0400 Subject: [PATCH] APMotors6DOF: Add motor reverse parameters for motors 9-12 Fix overruns found in coverity 145496-99 --- libraries/AP_Motors/AP_Motors6DOF.cpp | 30 ++++++++++++++++++++++++++- libraries/AP_Motors/AP_Motors6DOF.h | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Motors/AP_Motors6DOF.cpp b/libraries/AP_Motors/AP_Motors6DOF.cpp index c5c88f3a7a..4a27fd5a4e 100644 --- a/libraries/AP_Motors/AP_Motors6DOF.cpp +++ b/libraries/AP_Motors/AP_Motors6DOF.cpp @@ -89,6 +89,34 @@ const AP_Param::GroupInfo AP_Motors6DOF::var_info[] = { // @User: Standard AP_GROUPINFO("FV_CPLNG_K", 9, AP_Motors6DOF, _forwardVerticalCouplingFactor, 1.0), + // @Param: 9_DIRECTION + // @DisplayName: Motor normal or reverse + // @Description: Used to change motor rotation directions without changing wires + // @Values: 1:normal,-1:reverse + // @User: Standard + AP_GROUPINFO("9_DIRECTION", 10, AP_Motors6DOF, _motor_reverse[8], 1), + + // @Param: 10_DIRECTION + // @DisplayName: Motor normal or reverse + // @Description: Used to change motor rotation directions without changing wires + // @Values: 1:normal,-1:reverse + // @User: Standard + AP_GROUPINFO("10_DIRECTION", 11, AP_Motors6DOF, _motor_reverse[9], 1), + + // @Param: 11_DIRECTION + // @DisplayName: Motor normal or reverse + // @Description: Used to change motor rotation directions without changing wires + // @Values: 1:normal,-1:reverse + // @User: Standard + AP_GROUPINFO("11_DIRECTION", 12, AP_Motors6DOF, _motor_reverse[10], 1), + + // @Param: 12_DIRECTION + // @DisplayName: Motor normal or reverse + // @Description: Used to change motor rotation directions without changing wires + // @Values: 1:normal,-1:reverse + // @User: Standard + AP_GROUPINFO("12_DIRECTION", 13, AP_Motors6DOF, _motor_reverse[11], 1), + AP_GROUPEND }; @@ -366,7 +394,7 @@ void AP_Motors6DOF::output_armed_stabilizing_vectored() if (forward_coupling_limit < 0) { forward_coupling_limit = 0; } - int8_t forward_coupling_direction[] = {-1,-1,1,1,0,0,0,0}; + int8_t forward_coupling_direction[] = {-1,-1,1,1,0,0,0,0,0,0,0,0}; // calculate linear command for each motor // linear factors should be 0.0 or 1.0 for now diff --git a/libraries/AP_Motors/AP_Motors6DOF.h b/libraries/AP_Motors/AP_Motors6DOF.h index 83f409db49..a080fc315b 100644 --- a/libraries/AP_Motors/AP_Motors6DOF.h +++ b/libraries/AP_Motors/AP_Motors6DOF.h @@ -54,7 +54,7 @@ protected: void output_armed_stabilizing_vectored_6dof(); // Parameters - AP_Int8 _motor_reverse[8]; + AP_Int8 _motor_reverse[AP_MOTORS_MAX_NUM_MOTORS]; AP_Float _forwardVerticalCouplingFactor; float _throttle_factor[AP_MOTORS_MAX_NUM_MOTORS]; // each motors contribution to throttle (climb/descent)