From 8ce9aae2f78a402776f0b8fe6b0989dad0a68480 Mon Sep 17 00:00:00 2001 From: Robert Lefebvre Date: Fri, 13 Jul 2012 22:59:28 -0400 Subject: [PATCH] Instituting Yaw Differential on Multirotors. Intent is to stop "rise on yaw input". Since motors with increasing speed due to yaw input seem to generate more thrust that motors that slow lose thrust, thus net thrust goes up, causing copter to climb. Values are a guesstimate, proven out by test flying. This could probably become a parameter. --- libraries/AP_Motors/AP_MotorsMatrix.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Motors/AP_MotorsMatrix.cpp b/libraries/AP_Motors/AP_MotorsMatrix.cpp index 93944d1e37..ccb67ee9e1 100644 --- a/libraries/AP_Motors/AP_MotorsMatrix.cpp +++ b/libraries/AP_Motors/AP_MotorsMatrix.cpp @@ -125,6 +125,7 @@ void AP_MotorsMatrix::output_armed() int8_t i; int16_t out_min = _rc_throttle->radio_min; int16_t out_max = _rc_throttle->radio_max; + int16_t yaw_contribution = 0; // Throttle is 0 to 1000 only _rc_throttle->servo_out = constrain(_rc_throttle->servo_out, 0, _max_throttle); @@ -141,10 +142,16 @@ void AP_MotorsMatrix::output_armed() // mix roll, pitch, yaw, throttle into output for each motor for( i=0; ipwm_out*_yaw_factor[i]; + if (yaw_contribution > 0 ){ + yaw_contribution *= 0.7; + }else{ + yaw_contribution *= 1.42; + } motor_out[i] = _rc_throttle->radio_out + _rc_roll->pwm_out * _roll_factor[i] + _rc_pitch->pwm_out * _pitch_factor[i] + - _rc_yaw->pwm_out*_yaw_factor[i]; + yaw_contribution; } }