AP_Scheduler: constrain the load average

prevent numerical errors on logging load with SIM_TIME_JITTER
This commit is contained in:
Andrew Tridgell 2022-12-05 15:05:56 +11:00
parent 014c8a79e6
commit 47df6f0ab6

View File

@ -317,7 +317,7 @@ float AP_Scheduler::load_average()
}
const uint32_t loop_us = get_loop_period_us();
const uint32_t used_time = loop_us - (_spare_micros/_spare_ticks);
return used_time / (float)loop_us;
return constrain_float(used_time / (float)loop_us, 0, 1);
}
void AP_Scheduler::loop()