Bug in yaw expo range check?

Hi everyone,

I noticed it’s currently not possible to set ACRO_Y_EXPO to any value smaller than 0.5, except 0.
The desired value (let’s say 0.3) is overwritten to 1 at next reboot.

Is this normal? If not, maybe the range check performed in Attitude.cpp, lines 21-23, should be replaced by something like this:

if (g2.acro_y_expo > 1.0f) {
    g2.acro_y_expo = 1.0f;
}
else if (g2.acro_y_expo < -0.5f){
    g2.acro_y_expo = -0.5f;
}

Since this part of the code was written 4 years ago by @Leonardthall and @rmackay9 and no one complained about it since then, I didn’t dare to open an issue on ArduPilot’s GitHub :sweat_smile:
Maybe I don’t quite understand how this parameter works?

Thanks for support!

1 Like

Well done!!

Don’t ever be scared to put an issue into GitHub. Finding mistakes are the first step to fixing them!!

Thank you very much.

I will put a pull request in to fix this bug!

Cool, thanks!

To allow negative values, I just noticed that line 14 should also be replaced by:

if (g2.acro_y_expo == 0) {...}

Not sure many people will want negative expo, but it’s still nice to have the choice.

Yeh, I was thinking about this but I decided to stick to 0 to 1 range. The equation does work down to -0.5 but I do not believe that the utility of negative values justifies the potential for added support and mistakes.

It is also a change from intended behaviour and that requires significantly more input from the development team before I could murge the fix.

So for now I have done a PR to fix the bug and maintain the intended behavior.

Thanks again for pointing out the bug!! If I meet you in person I will buy you a drink :slight_smile: