mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-02 10:23:25 +08:00
AP_Scripting: avoid divide by zero in Lua script
This commit is contained in:
committed by
Willian Galvani
parent
29b250b476
commit
51cd2dd1c0
@@ -38,6 +38,9 @@ local function update()
|
||||
-- calculate dt
|
||||
local tnow = millis()
|
||||
local dt = (tnow - last_time_ms):tofloat() / 1000.0
|
||||
if dt <= 0 then
|
||||
return update, 1000 / RUN_HZ
|
||||
end
|
||||
-- cap dt to avoid a large integration step if execution was badly
|
||||
-- delayed, but otherwise integrate the time which actually elapsed.
|
||||
-- Substituting 1/RUN_HZ for a late callback discards the excess, and
|
||||
|
||||
Reference in New Issue
Block a user