mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-22 15:53:56 -04:00
AP_Scripting: add arming-check-batt-temp example script
This commit is contained in:
parent
ccaa74655c
commit
c0bc696b86
21
libraries/AP_Scripting/examples/arming-check-batt-temp .lua
Normal file
21
libraries/AP_Scripting/examples/arming-check-batt-temp .lua
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
-- This script runs a custom arming check of the battery temperature
|
||||||
|
|
||||||
|
auth_id = arming:get_aux_auth_id()
|
||||||
|
batt_temp_max = 35
|
||||||
|
|
||||||
|
function update() -- this is the loop which periodically runs
|
||||||
|
if auth_id then
|
||||||
|
now = millis()
|
||||||
|
batt_temp = battery:get_temperature(0)
|
||||||
|
if not batt_temp then
|
||||||
|
arming:set_aux_auth_failed(auth_id, "Could not retrieve battery temperature")
|
||||||
|
elseif (batt_temp >= batt_temp_max) then
|
||||||
|
arming:set_aux_auth_failed(auth_id, "Batt temp too high (" .. tostring(batt_temp) .. "C > " .. tostring(batt_temp_max) .. "C)")
|
||||||
|
else
|
||||||
|
arming:set_aux_auth_passed(auth_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return update, 5000 -- reschedules the loop in 5 seconds
|
||||||
|
end
|
||||||
|
|
||||||
|
return update() -- run immediately before starting to reschedule
|
Loading…
Reference in New Issue
Block a user