|
|
|
@ -712,3 +712,21 @@ int16_t AC_AttitudeControl::get_angle_boost(int16_t throttle_pwm)
@@ -712,3 +712,21 @@ int16_t AC_AttitudeControl::get_angle_boost(int16_t throttle_pwm)
|
|
|
|
|
|
|
|
|
|
return throttle_out; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// sqrt_controller - response based on the sqrt of the error instead of the more common linear response
|
|
|
|
|
float AC_AttitudeControl::sqrt_controller(float error, float p, float second_ord_lim) |
|
|
|
|
{ |
|
|
|
|
if (second_ord_lim == 0.0f || p == 0.0f) { |
|
|
|
|
return error*p; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
float linear_dist = second_ord_lim/sq(p); |
|
|
|
|
|
|
|
|
|
if (error > linear_dist) { |
|
|
|
|
return safe_sqrt(2.0f*second_ord_lim*(error-(linear_dist/2.0f))); |
|
|
|
|
} else if (error < -linear_dist) { |
|
|
|
|
return -safe_sqrt(2.0f*second_ord_lim*(-error-(linear_dist/2.0f))); |
|
|
|
|
} else { |
|
|
|
|
return error*p; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|