Skip to content

Commit

Permalink
Plane: Fix max. load factor formula
Browse files Browse the repository at this point in the history
The correct approximation for the max. load factor n_max at a specific
airspeed is n_max = (V_current / V_stall)^2. The roll limit was being
calculated correctly because the value was squared in that expression,
but the control flow was based on an incorrect value. This led to
slightly overcautious roll limits.

Adjusted the formula to be correct, and removed the squaring in the roll
limit calculation.
  • Loading branch information
rubenp02 committed Jan 16, 2025
1 parent 795eef0 commit 3c80a8d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ArduPlane/Attitude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ void Plane::update_load_factor(void)
}
#endif

float max_load_factor = smoothed_airspeed / MAX(aparm.airspeed_min, 1);
float max_load_factor = sq(smoothed_airspeed / MAX(aparm.airspeed_min, 1));
if (max_load_factor <= 1) {
// our airspeed is below the minimum airspeed. Limit roll to
// 25 degrees
Expand All @@ -668,13 +668,13 @@ void Plane::update_load_factor(void)
// load limit. Limit our roll to a bank angle that will keep
// the load within what the airframe can handle. We always
// allow at least 25 degrees of roll however, to ensure the
// aircraft can be manoeuvred with a bad airspeed estimate. At
// aircraft can be manoeuvered with a bad airspeed estimate. At
// 25 degrees the load factor is 1.1 (10%)
int32_t roll_limit = degrees(acosf(sq(1.0f / max_load_factor)))*100;
int32_t roll_limit = degrees(acosf(1.0f / max_load_factor))*100;
if (roll_limit < 2500) {
roll_limit = 2500;
}
nav_roll_cd = constrain_int32(nav_roll_cd, -roll_limit, roll_limit);
roll_limit_cd = MIN(roll_limit_cd, roll_limit);
}
}
}

0 comments on commit 3c80a8d

Please sign in to comment.