Skip to content

Commit

Permalink
AP_Scripting: modla ai scdript fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 committed Feb 20, 2024
1 parent 137569d commit b477b80
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions libraries/AP_Scripting/applets/ahrs-source-modalai-optflow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,25 @@
-- innovations are below ESRC_FLOW_THRESH
-- rangefinder distance is below ESRC_RNGFND_MAX

local PARAM_TABLE_KEY = 81
PARAM_TABLE_PREFIX = "ESRC_"
local MAV_SEVERITY = {EMERGENCY=0, ALERT=1, CRITICAL=2, ERROR=3, WARNING=4, NOTICE=5, INFO=6, DEBUG=7}

-- bind a parameter to a variable
function bind_param(name)
local p = Parameter()
assert(p:init(name), string.format('could not find %s parameter', name))
return p
end

-- add a parameter and bind it to a variable
function bind_add_param(name, idx, default_value)
local function bind_add_param(name, idx, default_value)
assert(param:add_param(PARAM_TABLE_KEY, idx, name, default_value), string.format('could not add param %s', name))
return Parameter(PARAM_TABLE_PREFIX .. name)
return bind_param(PARAM_TABLE_PREFIX .. name)
end

-- param table
local PARAM_TABLE_KEY = 81
PARAM_TABLE_PREFIX = "ESCR_"
assert(param:add_table(PARAM_TABLE_KEY, PARAM_TABLE_PREFIX, 6), 'ahrs-source-modalai-optflow: could not add param table')
-- add param table
assert(param:add_table(PARAM_TABLE_KEY, PARAM_TABLE_PREFIX, 5), 'ahrs-source-modalai-optflow: could not add param table')

--[[
// @Param: ESRC_EXTN_THRESH
Expand Down Expand Up @@ -227,7 +234,6 @@ function update()
end
play_source_tune(source_prev)
end
end

-- auto switching
if auto_switch and (auto_source >= 0) and (auto_source ~= source_prev) then
Expand Down

0 comments on commit b477b80

Please sign in to comment.