|
|
@ -44,10 +44,6 @@ static void acro_run() |
|
|
|
// returns desired angle rates in centi-degrees-per-second |
|
|
|
// returns desired angle rates in centi-degrees-per-second |
|
|
|
static void get_pilot_desired_angle_rates(int16_t roll_in, int16_t pitch_in, int16_t yaw_in, float &roll_out, float &pitch_out, float &yaw_out) |
|
|
|
static void get_pilot_desired_angle_rates(int16_t roll_in, int16_t pitch_in, int16_t yaw_in, float &roll_out, float &pitch_out, float &yaw_out) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// expo variables |
|
|
|
|
|
|
|
static float _expo_factor = 0.3; |
|
|
|
|
|
|
|
float rp_in, rp_in3, rp_out; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float rate_limit; |
|
|
|
float rate_limit; |
|
|
|
Vector3f rate_ef_level, rate_bf_level, rate_bf_request; |
|
|
|
Vector3f rate_ef_level, rate_bf_level, rate_bf_request; |
|
|
|
|
|
|
|
|
|
|
@ -55,17 +51,28 @@ static void get_pilot_desired_angle_rates(int16_t roll_in, int16_t pitch_in, int |
|
|
|
roll_in = constrain_int16(roll_in, -ROLL_PITCH_INPUT_MAX, ROLL_PITCH_INPUT_MAX); |
|
|
|
roll_in = constrain_int16(roll_in, -ROLL_PITCH_INPUT_MAX, ROLL_PITCH_INPUT_MAX); |
|
|
|
pitch_in = constrain_int16(pitch_in, -ROLL_PITCH_INPUT_MAX, ROLL_PITCH_INPUT_MAX); |
|
|
|
pitch_in = constrain_int16(pitch_in, -ROLL_PITCH_INPUT_MAX, ROLL_PITCH_INPUT_MAX); |
|
|
|
|
|
|
|
|
|
|
|
// calculate rate requests |
|
|
|
// calculate roll, pitch rate requests |
|
|
|
|
|
|
|
if (g.acro_expo <= 0) { |
|
|
|
|
|
|
|
rate_bf_request.x = roll_in * g.acro_rp_p; |
|
|
|
|
|
|
|
rate_bf_request.y = pitch_in * g.acro_rp_p; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// expo variables |
|
|
|
|
|
|
|
float rp_in, rp_in3, rp_out; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// roll expo |
|
|
|
rp_in = float(roll_in)/ROLL_PITCH_INPUT_MAX; |
|
|
|
rp_in = float(roll_in)/ROLL_PITCH_INPUT_MAX; |
|
|
|
rp_in3 = rp_in*rp_in*rp_in; |
|
|
|
rp_in3 = rp_in*rp_in*rp_in; |
|
|
|
rp_out = (_expo_factor * rp_in3) + ((1 - _expo_factor) * rp_in); |
|
|
|
rp_out = (g.acro_expo * rp_in3) + ((1 - g.acro_expo) * rp_in); |
|
|
|
rate_bf_request.x = ROLL_PITCH_INPUT_MAX * rp_out * g.acro_rp_p; |
|
|
|
rate_bf_request.x = ROLL_PITCH_INPUT_MAX * rp_out * g.acro_rp_p; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// pitch expo |
|
|
|
rp_in = float(pitch_in)/ROLL_PITCH_INPUT_MAX; |
|
|
|
rp_in = float(pitch_in)/ROLL_PITCH_INPUT_MAX; |
|
|
|
rp_in3 = rp_in*rp_in*rp_in; |
|
|
|
rp_in3 = rp_in*rp_in*rp_in; |
|
|
|
rp_out = (_expo_factor * rp_in3) + ((1 - _expo_factor) * rp_in); |
|
|
|
rp_out = (g.acro_expo * rp_in3) + ((1 - g.acro_expo) * rp_in); |
|
|
|
rate_bf_request.y = ROLL_PITCH_INPUT_MAX * rp_out * g.acro_rp_p; |
|
|
|
rate_bf_request.y = ROLL_PITCH_INPUT_MAX * rp_out * g.acro_rp_p; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// calculate yaw rate request |
|
|
|
rate_bf_request.z = yaw_in * g.acro_yaw_p; |
|
|
|
rate_bf_request.z = yaw_in * g.acro_yaw_p; |
|
|
|
|
|
|
|
|
|
|
|
// calculate earth frame rate corrections to pull the copter back to level while in ACRO mode |
|
|
|
// calculate earth frame rate corrections to pull the copter back to level while in ACRO mode |
|
|
|