L1_Control: constrain the roll to handle floating point errors

This commit is contained in:
Andrew Tridgell 2013-04-15 14:29:39 +10:00
parent 83dc7dbc92
commit 97bfd16bd1

View File

@ -37,8 +37,9 @@ const AP_Param::GroupInfo AP_L1_Control::var_info[] PROGMEM = {
*/
int32_t AP_L1_Control::nav_roll_cd(void)
{
int32_t ret;
float ret;
ret = degrees(atanf(_latAccDem * 0.101972f) * 100.0f); // 0.101972 = 1/9.81
ret = constrain(ret, -9000, 9000);
return ret;
}