Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgenTech: engine-out: if engine dies low, qland #2

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading