AP_Scheduler: load_average returns 1 if main loop running slowly

This commit is contained in:
Randy Mackay 2022-11-30 20:13:07 +09:00 committed by Andrew Tridgell
parent d9aa366b59
commit 064627de04
1 changed files with 4 additions and 0 deletions

View File

@ -308,6 +308,10 @@ uint16_t AP_Scheduler::time_available_usec(void) const
*/
float AP_Scheduler::load_average()
{
// return 1 if filtered main loop rate is 5% below the configured rate
if (get_filtered_loop_rate_hz() < get_loop_rate_hz() * 0.95) {
return 1.0;
}
if (_spare_ticks == 0) {
return 0.0f;
}