ACRO_RP_P and ACRO_RP_EXPO range check

Hello! Is there any specific reason to check only ACRO_RP_EXPO parameter’s value when transforming pilot’s roll pitch and yaw input into a desired lean angle rates? This is because ACRO_RP_P parameter also affects the desired angle rates.

// range check expo
g.acro_rp_expo = constrain_float(g.acro_rp_expo, 0.0f, 1.0f);

// calculate roll, pitch rate requests
if (is_zero(g.acro_rp_expo)) {
    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_YAW_INPUT_MAX;
    rp_in3 = rp_in*rp_in*rp_in;
    rp_out = (g.acro_rp_expo * rp_in3) + ((1.0f - g.acro_rp_expo) * rp_in);
    rate_bf_request.x = ROLL_PITCH_YAW_INPUT_MAX * rp_out * g.acro_rp_p;

    // pitch expo
    rp_in = float(pitch_in)/ROLL_PITCH_YAW_INPUT_MAX;
    rp_in3 = rp_in*rp_in*rp_in;
    rp_out = (g.acro_rp_expo * rp_in3) + ((1.0f - g.acro_rp_expo) * rp_in);
    rate_bf_request.y = ROLL_PITCH_YAW_INPUT_MAX * rp_out * g.acro_rp_p;
}

Extracted from “ArduPilot/ardupilot/blob/master/ArduCopter/mode_acro.cpp”

1 Like

Thanks again @KimHyungSub,

Leonard says the constraint is incorrect so we’re going to close this PR and then someone needs to fix the code by raising a new PR.

1 Like