mirror of https://github.com/ArduPilot/ardupilot
AP_Scripting: setup axis filters when starting an axis
This commit is contained in:
parent
4bc697dfa2
commit
998072f600
|
@ -104,6 +104,7 @@ local slew_target = 0
|
||||||
local slew_delta = 0
|
local slew_delta = 0
|
||||||
|
|
||||||
local axes_done = {}
|
local axes_done = {}
|
||||||
|
local filters_done = {}
|
||||||
|
|
||||||
|
|
||||||
-- create params dictionary indexed by name, such as "RLL_P"
|
-- create params dictionary indexed by name, such as "RLL_P"
|
||||||
|
@ -124,6 +125,7 @@ end
|
||||||
function reset_axes_done()
|
function reset_axes_done()
|
||||||
for i, axis in ipairs(axis_names) do
|
for i, axis in ipairs(axis_names) do
|
||||||
axes_done[axis] = false
|
axes_done[axis] = false
|
||||||
|
filters_done[axis] = false
|
||||||
end
|
end
|
||||||
stage = stages[1]
|
stage = stages[1]
|
||||||
end
|
end
|
||||||
|
@ -168,25 +170,19 @@ function setup_SMAX()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- setup filter frequencies
|
-- setup filter frequencies
|
||||||
function setup_filters()
|
function setup_filters(axis)
|
||||||
if QUIK_AUTO_FILTER:get() <= 0 then
|
local fltd = axis .. "_FLTD"
|
||||||
return
|
local fltt = axis .. "_FLTT"
|
||||||
end
|
local flte = axis .. "_FLTE"
|
||||||
for i, axis in ipairs(axis_names) do
|
adjust_gain(fltt, INS_GYRO_FILTER:get() * FLTT_MUL)
|
||||||
if axis_enabled(axis) then
|
adjust_gain(fltd, INS_GYRO_FILTER:get() * FLTD_MUL)
|
||||||
local fltd = axis .. "_FLTD"
|
if axis == "YAW" then
|
||||||
local fltt = axis .. "_FLTT"
|
local FLTE = params[flte]
|
||||||
local flte = axis .. "_FLTE"
|
if FLTE:get() <= 0.0 or FLTE:get() > YAW_FLTE_MAX then
|
||||||
adjust_gain(fltt, INS_GYRO_FILTER:get() * FLTT_MUL)
|
adjust_gain(flte, YAW_FLTE_MAX)
|
||||||
adjust_gain(fltd, INS_GYRO_FILTER:get() * FLTD_MUL)
|
|
||||||
if axis == "YAW" then
|
|
||||||
local FLTE = params[flte]
|
|
||||||
if FLTE:get() <= 0.0 or FLTE:get() > YAW_FLTE_MAX then
|
|
||||||
adjust_gain(flte, YAW_FLTE_MAX)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
filters_done[axis] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check for pilot input to pause tune
|
-- check for pilot input to pause tune
|
||||||
|
@ -421,13 +417,17 @@ function update()
|
||||||
gcs:send_text(MAV_SEVERITY_NOTICE, string.format("Tuning: starting tune"))
|
gcs:send_text(MAV_SEVERITY_NOTICE, string.format("Tuning: starting tune"))
|
||||||
get_all_params()
|
get_all_params()
|
||||||
setup_SMAX()
|
setup_SMAX()
|
||||||
setup_filters()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if get_time() - last_pilot_input < PILOT_INPUT_DELAY then
|
if get_time() - last_pilot_input < PILOT_INPUT_DELAY then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not filters_done[axis] then
|
||||||
|
gcs:send_text(MAV_SEVERITY_INFO, string.format("Starting %s tune", axis))
|
||||||
|
setup_filters(axis)
|
||||||
|
end
|
||||||
|
|
||||||
local srate = get_slew_rate(axis)
|
local srate = get_slew_rate(axis)
|
||||||
local pname = get_pname(axis, stage)
|
local pname = get_pname(axis, stage)
|
||||||
local P = params[pname]
|
local P = params[pname]
|
||||||
|
|
Loading…
Reference in New Issue