Skip to content

Commit

Permalink
ArgenTech: engine-out: if engine dies low, qland
Browse files Browse the repository at this point in the history
If the engine dies early, before we have climbed above the hard deck,
the last thing we want to do is RTL. QLand is a better option. QRTL
would be best, but we don't have time to carefully consider the edge
cases yet.
  • Loading branch information
robertlong13 committed Apr 24, 2024
1 parent ed196f5 commit d069d49
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions libraries/AP_Scripting/applets/engine_out.lua
Original file line number Diff line number Diff line change
Expand Up @@ -261,22 +261,6 @@ local function check_engine()
-- Otherwise, the engine is definitely not running
set_engine_state(true)
end

local function do_engine_failsafe()
--[[
Trigger the RTL upon engine failure. This includes reconfiguring some
parameters. This should only be called once to initiate the failsafe.
--]]

-- We don't want to do the mission based autoland, so disable RTL_AUTOLAND
engineFailsafeParamGroup:set_parameter("RTL_AUTOLAND", 0)
-- We don't want any automatic QRTL behavior
engineFailsafeParamGroup:set_parameter("Q_RTL_MODE", 0)

-- Trigger an RTL to start bringing the vehicle or to the nearest rally point
-- if set or go to home if no rally point available within the RALLY_LIMIT_KM
vehicle:set_mode(MODE_RTL)
end

local function switch_qland(reason)
--[[
Expand Down Expand Up @@ -307,6 +291,29 @@ local function switch_qrtl(reason)
vehicle:set_mode(MODE_QRTL)
end

local function do_engine_failsafe()
--[[
Trigger the RTL upon engine failure. This includes reconfiguring some
parameters. This should only be called once to initiate the failsafe.
--]]

-- We don't want to do the mission based autoland, so disable RTL_AUTOLAND
engineFailsafeParamGroup:set_parameter("RTL_AUTOLAND", 0)
-- We don't want any automatic QRTL behavior
engineFailsafeParamGroup:set_parameter("Q_RTL_MODE", 0)

-- If we are already low, then RTL is a bad idea. Instead, switch to QLand
local height_agl = utilities.relative_ground_altitude(true, true)
if height_agl and height_agl < Q_RTL_ALT:get() then
switch_qland("Engine out and below minimum altitude")
return
end

-- Trigger an RTL to start bringing the vehicle or to the nearest rally point
-- if set or go to home if no rally point available within the RALLY_LIMIT_KM
vehicle:set_mode(MODE_RTL)
end

local function reset_target_alt()
--[[
Reset the target altitude to Q_RTL_ALT, and set it to the terrain altitude
Expand Down

0 comments on commit d069d49

Please sign in to comment.