mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-11 19:58:22 +00:00
#TARS - Added TARS_SESSION.debugunitsearch = false and F10 search zone draw for debugging
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
-- @type TARS_SESSION
|
-- @type TARS_SESSION
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
-- @field #boolean debug Enable debugging in TARS_SESSION.
|
-- @field #boolean debug Enable debugging in TARS_SESSION.
|
||||||
|
-- @field #boolean debugunitsearch Enable Target Search Debug.
|
||||||
-- @field Wrapper.Unit#UNIT unit The MOOSE UNIT object for the recon aircraft.
|
-- @field Wrapper.Unit#UNIT unit The MOOSE UNIT object for the recon aircraft.
|
||||||
-- @field #string lid Log-line prefix shown in Moose.log entries.
|
-- @field #string lid Log-line prefix shown in Moose.log entries.
|
||||||
-- @field DCS#Vec3 vec3 World position snapshot taken at session creation.
|
-- @field DCS#Vec3 vec3 World position snapshot taken at session creation.
|
||||||
@@ -57,6 +58,7 @@
|
|||||||
-- @field #TARS_SESSION
|
-- @field #TARS_SESSION
|
||||||
TARS_SESSION = {}
|
TARS_SESSION = {}
|
||||||
TARS_SESSION.debug = false
|
TARS_SESSION.debug = false
|
||||||
|
TARS_SESSION.debugunitsearch = false
|
||||||
|
|
||||||
--- @type TARS
|
--- @type TARS
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
@@ -146,7 +148,7 @@ TARS_SESSION.debug = false
|
|||||||
--
|
--
|
||||||
-- TARS_Instance.reconTypes["F-16C_50"] = true
|
-- TARS_Instance.reconTypes["F-16C_50"] = true
|
||||||
-- TARS_Instance.parameters["F-16C_50"] = {
|
-- TARS_Instance.parameters["F-16C_50"] = {
|
||||||
-- minAlt=300, maxAlt=8000, maxRoll=10, maxPitch=15,
|
-- minAlt=300, maxAlt=8000, maxRoll=10, maxPitch=15, -- Note altitude is AGL!
|
||||||
-- fov=35, duration=300, offset=math.rad(20),
|
-- fov=35, duration=300, offset=math.rad(20),
|
||||||
-- name="F-16C with RECCE pod"
|
-- name="F-16C with RECCE pod"
|
||||||
-- }
|
-- }
|
||||||
@@ -280,7 +282,7 @@ TARS = {}
|
|||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
--- @field #string version
|
--- @field #string version
|
||||||
TARS.version = "v2.2.1"
|
TARS.version = "v2.2.2"
|
||||||
|
|
||||||
--- Active locale.
|
--- Active locale.
|
||||||
-- @field #string locale
|
-- @field #string locale
|
||||||
@@ -356,7 +358,8 @@ TARS.reconTypes = {
|
|||||||
-- TODO PER-PLATFORM PARAMETERS
|
-- TODO PER-PLATFORM PARAMETERS
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
--- @field #table parameters
|
--- @type #TARS.parameters
|
||||||
|
-- @field #table parameters
|
||||||
TARS.parameters = {}
|
TARS.parameters = {}
|
||||||
|
|
||||||
TARS.parameters["F-4E-45MC"] = { minAlt=100, maxAlt=6096, maxRoll=10, maxPitch=15, fov=23, duration=120, offset=math.rad(60), name="RF-4E with KS-87 Forward Oblique Camera" }
|
TARS.parameters["F-4E-45MC"] = { minAlt=100, maxAlt=6096, maxRoll=10, maxPitch=15, fov=23, duration=120, offset=math.rad(60), name="RF-4E with KS-87 Forward Oblique Camera" }
|
||||||
@@ -950,12 +953,13 @@ end
|
|||||||
function TARS_SESSION:FindTargets()
|
function TARS_SESSION:FindTargets()
|
||||||
local unit = self.unit
|
local unit = self.unit
|
||||||
local vec3 = unit:GetVec3()
|
local vec3 = unit:GetVec3()
|
||||||
local MSL = land.getHeight({ x = vec3.x, y = vec3.z })
|
--local MSL = land.getHeight({ x = vec3.x, y = vec3.z })
|
||||||
local alt = vec3.y - MSL
|
--local alt = vec3.y - MSL
|
||||||
local params = self.Callback.parameters[self.type]
|
local alt = unit:GetAltitude(true)
|
||||||
|
local params = self.Callback.parameters[self.type] -- #TARS.parameters
|
||||||
|
|
||||||
local roll = math.abs(math.deg(TARS.getRoll(unit)))
|
local roll = math.abs(TARS.getRoll(unit))
|
||||||
local pitch = math.abs(math.deg(TARS.getPitch(unit)))
|
local pitch = math.abs(TARS.getPitch(unit))
|
||||||
local isFlat = roll < params.maxRoll and pitch < params.maxPitch
|
local isFlat = roll < params.maxRoll and pitch < params.maxPitch
|
||||||
|
|
||||||
local radius = params.optimalAlt
|
local radius = params.optimalAlt
|
||||||
@@ -967,6 +971,34 @@ function TARS_SESSION:FindTargets()
|
|||||||
coordinate = coordinate:UpdateFromVec3({ x=offset.x, y=MSL, z=offset.z })
|
coordinate = coordinate:UpdateFromVec3({ x=offset.x, y=MSL, z=offset.z })
|
||||||
self.coordinate = coordinate
|
self.coordinate = coordinate
|
||||||
|
|
||||||
|
if self.debugunitsearch then
|
||||||
|
-- TODO Search Zone Debug
|
||||||
|
-- Draw the searczone on the F10 map
|
||||||
|
local searchzone = self.searchzone or ZONE_RADIUS:New("TARS Debug",coordinate:GetVec2(),radius,true)
|
||||||
|
|
||||||
|
if searchzone then
|
||||||
|
searchzone:UndrawZone()
|
||||||
|
searchzone:UpdateFromVec2(coordinate:GetVec2(),radius)
|
||||||
|
self.searchzone = searchzone
|
||||||
|
searchzone:DrawZone(-1,{0,0,1},1,{0,1,0},.2,2,true)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- TODO Params check and output
|
||||||
|
if params and unit and unit:IsAlive() then
|
||||||
|
self:I({Roll=roll,Pitch=pitch,AGL=alt})
|
||||||
|
if roll > params.maxRoll then
|
||||||
|
MESSAGE:New(string.format("Roll - NOK out of parameters (%d°)!",roll or 0),9,"PARAM"):ToUnit(unit)
|
||||||
|
elseif pitch > params.maxPitch then
|
||||||
|
MESSAGE:New(string.format("Pitch - NOK out of parameters (%d°)!", pitch or 0),9,"PARAM"):ToUnit(unit)
|
||||||
|
elseif alt < params.minAlt or alt > params.maxAlt then
|
||||||
|
MESSAGE:New(string.format("AGL - NOK too high or too low (%dm)!", alt or 0),9,"PARAM"):ToUnit(unit)
|
||||||
|
else
|
||||||
|
MESSAGE:New("Params - OK!",9,"PARAM"):ToUnit(unit)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
local debugunitset
|
local debugunitset
|
||||||
if self.debug == true then
|
if self.debug == true then
|
||||||
self:I(self.lid.."FindTargets Debug SET_UNIT created")
|
self:I(self.lid.."FindTargets Debug SET_UNIT created")
|
||||||
|
|||||||
Reference in New Issue
Block a user