mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Ops
This commit is contained in:
parent
cf65c2af15
commit
200c1dac85
@ -233,17 +233,18 @@ function ARMYGROUP:onafterStatus(From, Event, To)
|
|||||||
|
|
||||||
-- FSM state.
|
-- FSM state.
|
||||||
local fsmstate=self:GetState()
|
local fsmstate=self:GetState()
|
||||||
|
|
||||||
|
if self:IsAlive() then
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Detection
|
||||||
|
---
|
||||||
|
|
||||||
|
-- Check if group has detected any units.
|
||||||
|
if self.detectionOn then
|
||||||
|
self:_CheckDetectedUnits()
|
||||||
|
end
|
||||||
|
|
||||||
---
|
|
||||||
-- Detection
|
|
||||||
---
|
|
||||||
|
|
||||||
-- Check if group has detected any units.
|
|
||||||
if self.detectionOn then
|
|
||||||
self:_CheckDetectedUnits()
|
|
||||||
end
|
|
||||||
|
|
||||||
if self:IsAlive() and not self:IsDead() then
|
|
||||||
|
|
||||||
-- Current heading and position of the carrier.
|
-- Current heading and position of the carrier.
|
||||||
local hdg=self:GetHeading()
|
local hdg=self:GetHeading()
|
||||||
@ -276,6 +277,7 @@ function ARMYGROUP:onafterStatus(From, Event, To)
|
|||||||
self:_PrintTaskAndMissionStatus()
|
self:_PrintTaskAndMissionStatus()
|
||||||
|
|
||||||
|
|
||||||
|
-- Next status update.
|
||||||
self:__Status(-30)
|
self:__Status(-30)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -95,10 +95,9 @@ function NAVYGROUP:New(GroupName)
|
|||||||
self.lid=string.format("NAVYGROUP %s | ", self.groupname)
|
self.lid=string.format("NAVYGROUP %s | ", self.groupname)
|
||||||
|
|
||||||
-- Defaults
|
-- Defaults
|
||||||
--self:SetDefaultROE()
|
|
||||||
--self:SetDefaultAlarmstate()
|
|
||||||
self:SetDetection()
|
self:SetDetection()
|
||||||
self:SetPatrolAdInfinitum(true)
|
self:SetPatrolAdInfinitum(true)
|
||||||
|
self:SetPathfinding(false)
|
||||||
|
|
||||||
-- Add FSM transitions.
|
-- Add FSM transitions.
|
||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
@ -181,7 +180,7 @@ end
|
|||||||
|
|
||||||
--- Enable/disable pathfinding.
|
--- Enable/disable pathfinding.
|
||||||
-- @param #NAVYGROUP self
|
-- @param #NAVYGROUP self
|
||||||
-- @param #boolean switch If true, enable pathfinding.
|
-- @param #boolean Switch If true, enable pathfinding.
|
||||||
-- @return #NAVYGROUP self
|
-- @return #NAVYGROUP self
|
||||||
function NAVYGROUP:SetPathfinding(Switch)
|
function NAVYGROUP:SetPathfinding(Switch)
|
||||||
self.pathfindingOn=Switch
|
self.pathfindingOn=Switch
|
||||||
@ -400,17 +399,17 @@ function NAVYGROUP:onafterStatus(From, Event, To)
|
|||||||
|
|
||||||
-- FSM state.
|
-- FSM state.
|
||||||
local fsmstate=self:GetState()
|
local fsmstate=self:GetState()
|
||||||
|
|
||||||
---
|
|
||||||
-- Detection
|
|
||||||
---
|
|
||||||
|
|
||||||
-- Check if group has detected any units.
|
if self:IsAlive() then
|
||||||
if self.detectionOn then
|
|
||||||
self:_CheckDetectedUnits()
|
|
||||||
end
|
|
||||||
|
|
||||||
if self:IsAlive() and not self:IsDead() then
|
---
|
||||||
|
-- Detection
|
||||||
|
---
|
||||||
|
|
||||||
|
-- Check if group has detected any units.
|
||||||
|
if self.detectionOn then
|
||||||
|
self:_CheckDetectedUnits()
|
||||||
|
end
|
||||||
|
|
||||||
-- Current heading and position of the carrier.
|
-- Current heading and position of the carrier.
|
||||||
local hdg=self:GetHeading()
|
local hdg=self:GetHeading()
|
||||||
@ -420,8 +419,7 @@ function NAVYGROUP:onafterStatus(From, Event, To)
|
|||||||
-- Check if group started or stopped turning.
|
-- Check if group started or stopped turning.
|
||||||
self:_CheckTurning()
|
self:_CheckTurning()
|
||||||
|
|
||||||
local freepath=10000
|
local freepath=UTILS.NMToMeters(10)
|
||||||
local collision=false
|
|
||||||
|
|
||||||
-- Only check if not currently turning.
|
-- Only check if not currently turning.
|
||||||
if not self:IsTurning() then
|
if not self:IsTurning() then
|
||||||
@ -429,15 +427,14 @@ function NAVYGROUP:onafterStatus(From, Event, To)
|
|||||||
-- Check free path ahead.
|
-- Check free path ahead.
|
||||||
freepath=self:_CheckFreePath(freepath, 100)
|
freepath=self:_CheckFreePath(freepath, 100)
|
||||||
|
|
||||||
if freepath<5000 and not self.collisionwarning then
|
if freepath<5000 then
|
||||||
|
|
||||||
-- Issue a collision warning event.
|
if not self.collisionwarning then
|
||||||
self:CollisionWarning()
|
-- Issue a collision warning event.
|
||||||
end
|
self:CollisionWarning(freepath)
|
||||||
|
end
|
||||||
|
|
||||||
if not self.ispathfinding then
|
if self.pathfindingOn and not self.ispathfinding then
|
||||||
|
|
||||||
if freepath<5000 then
|
|
||||||
self.ispathfinding=self:_FindPathToNextWaypoint()
|
self.ispathfinding=self:_FindPathToNextWaypoint()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -885,7 +882,9 @@ end
|
|||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function NAVYGROUP:onafterCollisionWarning(From, Event, To)
|
-- @param #number Distance Distance in meters where obstacle was detected.
|
||||||
|
function NAVYGROUP:onafterCollisionWarning(From, Event, To, Distance)
|
||||||
|
self:I(self.lid..string.format("Iceberg ahead in %d meters!", Distance or -1))
|
||||||
self.collisionwarning=true
|
self.collisionwarning=true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1039,8 +1038,9 @@ end
|
|||||||
-- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table.
|
-- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table.
|
||||||
function NAVYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Depth, Updateroute)
|
function NAVYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Depth, Updateroute)
|
||||||
|
|
||||||
|
-- Check if a coordinate was given or at least a positionable.
|
||||||
if not Coordinate:IsInstanceOf("COORDINATE") then
|
if not Coordinate:IsInstanceOf("COORDINATE") then
|
||||||
if Coordinate:IsInstanceOf("POSITIONABLE") then
|
if Coordinate:IsInstanceOf("POSITIONABLE") or Coordinate:IsInstanceOf("ZONE_BASE") then
|
||||||
self:I(self.lid.."WARNING: Coordinate is not a COORDINATE but a POSITIONABLE. Trying to get coordinate")
|
self:I(self.lid.."WARNING: Coordinate is not a COORDINATE but a POSITIONABLE. Trying to get coordinate")
|
||||||
Coordinate=Coordinate:GetCoordinate()
|
Coordinate=Coordinate:GetCoordinate()
|
||||||
else
|
else
|
||||||
@ -1198,6 +1198,8 @@ end
|
|||||||
|
|
||||||
--- Check for possible collisions between two coordinates.
|
--- Check for possible collisions between two coordinates.
|
||||||
-- @param #NAVYGROUP self
|
-- @param #NAVYGROUP self
|
||||||
|
-- @param #number DistanceMax Max distance in meters ahead to check. Default 5000.
|
||||||
|
-- @param #number dx
|
||||||
-- @return #number Free distance in meters.
|
-- @return #number Free distance in meters.
|
||||||
function NAVYGROUP:_CheckFreePath(DistanceMax, dx)
|
function NAVYGROUP:_CheckFreePath(DistanceMax, dx)
|
||||||
|
|
||||||
@ -1252,7 +1254,8 @@ function NAVYGROUP:_CheckFreePath(DistanceMax, dx)
|
|||||||
|
|
||||||
local los=LoS(x)
|
local los=LoS(x)
|
||||||
|
|
||||||
env.info(string.format("N=%d: xmin=%.1f xmax=%.1f x=%.1f d=%.3f los=%s", N, xmin, xmax, x, d, tostring(los)))
|
-- Debug message.
|
||||||
|
self:T(self.lid..string.format("N=%d: xmin=%.1f xmax=%.1f x=%.1f d=%.3f los=%s", N, xmin, xmax, x, d, tostring(los)))
|
||||||
|
|
||||||
if los and d<=eps then
|
if los and d<=eps then
|
||||||
return x
|
return x
|
||||||
|
|||||||
@ -2292,26 +2292,31 @@ end
|
|||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #number n The goto waypoint number.
|
-- @param #number UID The goto waypoint unique ID.
|
||||||
function OPSGROUP:onafterGotoWaypoint(From, Event, To, n)
|
function OPSGROUP:onafterGotoWaypoint(From, Event, To, UID)
|
||||||
|
|
||||||
-- The last waypoint passed was n-1
|
local n=self:GetWaypointIndex(UID)
|
||||||
self.currentwp=n-1
|
|
||||||
|
|
||||||
-- TODO: switch to re-enable waypoint tasks.
|
if n then
|
||||||
if false then
|
|
||||||
local tasks=self:GetTasksWaypoint(n)
|
-- TODO: switch to re-enable waypoint tasks.
|
||||||
|
if false then
|
||||||
for _,_task in pairs(tasks) do
|
local tasks=self:GetTasksWaypoint(n)
|
||||||
local task=_task --#OPSGROUP.Task
|
|
||||||
task.status=OPSGROUP.TaskStatus.SCHEDULED
|
for _,_task in pairs(tasks) do
|
||||||
|
local task=_task --#OPSGROUP.Task
|
||||||
|
task.status=OPSGROUP.TaskStatus.SCHEDULED
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local Speed=self:GetSpeedToWaypoint(n)
|
||||||
|
|
||||||
|
-- Update the route.
|
||||||
|
self:__UpdateRoute(-1, n, Speed)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update the route.
|
|
||||||
self:UpdateRoute()
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "DetectedUnit" event. Add newly detected unit to detected units set.
|
--- On after "DetectedUnit" event. Add newly detected unit to detected units set.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user