mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPSGROUP
- Ad infinitum fixes - Turn into wind fixes
This commit is contained in:
parent
538864519e
commit
0b5edfc21f
@ -589,10 +589,11 @@ end
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param #number n Waypoint number. Default is next waypoint.
|
||||
-- @param #number n Next waypoint index. Default is the one coming after that one that has been passed last.
|
||||
-- @param #number N Waypoint Max waypoint index to be included in the route. Default is the final waypoint.
|
||||
-- @param #number Speed Speed in knots. Default cruise speed.
|
||||
-- @param #number Formation Formation of the group.
|
||||
function ARMYGROUP:onbeforeUpdateRoute(From, Event, To, n, Speed, Formation)
|
||||
function ARMYGROUP:onbeforeUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
||||
if self:IsWaiting() then
|
||||
self:E(self.lid.."Update route denied. Group is WAIRING!")
|
||||
return false
|
||||
@ -614,20 +615,22 @@ end
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param #number n Waypoint number. Default is next waypoint.
|
||||
-- @param #number n Next waypoint index. Default is the one coming after that one that has been passed last.
|
||||
-- @param #number N Waypoint Max waypoint index to be included in the route. Default is the final waypoint.
|
||||
-- @param #number Speed Speed in knots. Default cruise speed.
|
||||
-- @param #number Formation Formation of the group.
|
||||
function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Formation)
|
||||
function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
||||
|
||||
-- Debug info.
|
||||
local text=string.format("Update route state=%s: n=%s, Speed=%s, Formation=%s", self:GetState(), tostring(n), tostring(Speed), tostring(Formation))
|
||||
local text=string.format("Update route state=%s: n=%s, N=%s, Speed=%s, Formation=%s", self:GetState(), tostring(n), tostring(N), tostring(Speed), tostring(Formation))
|
||||
self:T(self.lid..text)
|
||||
|
||||
-- Update route from this waypoint number onwards.
|
||||
n=n or self:GetWaypointIndexNext(self.adinfinitum)
|
||||
|
||||
-- Update waypoint tasks, i.e. inject WP tasks into waypoint table. OBSOLETE!
|
||||
--self:_UpdateWaypointTasks(n)
|
||||
-- Max index.
|
||||
N=N or #self.waypoints
|
||||
N=math.min(N, #self.waypoints)
|
||||
|
||||
-- Waypoints.
|
||||
local waypoints={}
|
||||
@ -740,26 +743,13 @@ function ARMYGROUP:onafterGotoWaypoint(From, Event, To, UID, Speed, Formation)
|
||||
|
||||
local n=self:GetWaypointIndex(UID)
|
||||
|
||||
--env.info(string.format("FF AG Goto waypoint UID=%s Index=%s, Speed=%s, Formation=%s", tostring(UID), tostring(n), tostring(Speed), tostring(Formation)))
|
||||
|
||||
if n then
|
||||
|
||||
-- TODO: switch to re-enable waypoint tasks.
|
||||
if false then
|
||||
local tasks=self:GetTasksWaypoint(n)
|
||||
|
||||
for _,_task in pairs(tasks) do
|
||||
local task=_task --Ops.OpsGroup#OPSGROUP.Task
|
||||
task.status=OPSGROUP.TaskStatus.SCHEDULED
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Speed to waypoint.
|
||||
Speed=Speed or self:GetSpeedToWaypoint(n)
|
||||
|
||||
-- Update the route.
|
||||
self:UpdateRoute(n, Speed, Formation)
|
||||
self:__UpdateRoute(-0.01, n, nil, Speed, Formation)
|
||||
|
||||
end
|
||||
|
||||
@ -1132,7 +1122,7 @@ function ARMYGROUP:onafterCruise(From, Event, To, Speed, Formation)
|
||||
self.Twaiting=nil
|
||||
self.dTwait=nil
|
||||
|
||||
self:__UpdateRoute(-1, nil, Speed, Formation)
|
||||
self:__UpdateRoute(-1, nil, nil, Speed, Formation)
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -1970,9 +1970,10 @@ end
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param #number n Waypoint number.
|
||||
-- @param #number n Next waypoint index. Default is the one coming after that one that has been passed last.
|
||||
-- @param #number N Waypoint Max waypoint index to be included in the route. Default is the final waypoint.
|
||||
-- @return #boolean Transision allowed?
|
||||
function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n)
|
||||
function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n, N)
|
||||
|
||||
-- Is transition allowed? We assume yes until proven otherwise.
|
||||
local allowed=true
|
||||
@ -2012,8 +2013,8 @@ function FLIGHTGROUP:onbeforeUpdateRoute(From, Event, To, n)
|
||||
allowed=false
|
||||
end
|
||||
|
||||
local N=n or self.currentwp+1
|
||||
if not N or N<1 then
|
||||
local Nn=n or self.currentwp+1
|
||||
if not Nn or Nn<1 then
|
||||
self:E(self.lid.."Update route denied because N=nil or N<1")
|
||||
trepeat=-5
|
||||
allowed=false
|
||||
@ -2071,14 +2072,16 @@ end
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param #number n Waypoint number. Default is next waypoint.
|
||||
function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
||||
-- @param #number n Next waypoint index. Default is the one coming after that one that has been passed last.
|
||||
-- @param #number N Waypoint Max waypoint index to be included in the route. Default is the final waypoint.
|
||||
function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n, N)
|
||||
|
||||
-- Update route from this waypoint number onwards.
|
||||
n=n or self.currentwp+1
|
||||
|
||||
-- Update waypoint tasks, i.e. inject WP tasks into waypoint table.
|
||||
self:_UpdateWaypointTasks(n)
|
||||
-- Max index.
|
||||
N=N or #self.waypoints
|
||||
N=math.min(N, #self.waypoints)
|
||||
|
||||
-- Waypoints.
|
||||
local wp={}
|
||||
@ -2100,10 +2103,8 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
||||
local current=self.group:GetCoordinate():WaypointAir(COORDINATE.WaypointAltType.BARO, waypointType, waypointAction, speed, true, nil, {}, "Current")
|
||||
table.insert(wp, current)
|
||||
|
||||
local Nwp=self.waypoints and #self.waypoints or 0
|
||||
|
||||
-- Add remaining waypoints to route.
|
||||
for i=n, Nwp do
|
||||
for i=n, N do
|
||||
table.insert(wp, self.waypoints[i])
|
||||
end
|
||||
|
||||
|
||||
@ -710,12 +710,13 @@ end
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param #number n Waypoint number. Default is next waypoint.
|
||||
-- @param #number n Next waypoint index. Default is the one coming after that one that has been passed last.
|
||||
-- @param #number N Waypoint Max waypoint index to be included in the route. Default is the final waypoint.
|
||||
-- @param #number Speed Speed in knots to the next waypoint.
|
||||
-- @param #number Depth Depth in meters to the next waypoint.
|
||||
function NAVYGROUP:onbeforeUpdateRoute(From, Event, To, n, Speed, Depth)
|
||||
if self:IsWaiting() then
|
||||
self:E(self.lid.."Update route denied. Group is WAIRING!")
|
||||
self:E(self.lid.."Update route denied. Group is WAITING!")
|
||||
return false
|
||||
elseif self:IsInUtero() then
|
||||
self:E(self.lid.."Update route denied. Group is INUTERO!")
|
||||
@ -735,21 +736,24 @@ end
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param #number n Waypoint number. Default is next waypoint.
|
||||
-- @param #number n Next waypoint index. Default is the one coming after that one that has been passed last.
|
||||
-- @param #number N Waypoint Max waypoint index to be included in the route. Default is the final waypoint.
|
||||
-- @param #number Speed Speed in knots to the next waypoint.
|
||||
-- @param #number Depth Depth in meters to the next waypoint.
|
||||
function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
|
||||
function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Depth)
|
||||
|
||||
-- Update route from this waypoint number onwards.
|
||||
n=n or self:GetWaypointIndexNext()
|
||||
|
||||
-- Update waypoint tasks, i.e. inject WP tasks into waypoint table.
|
||||
--self:_UpdateWaypointTasks(n)
|
||||
-- Max index.
|
||||
N=N or #self.waypoints
|
||||
N=math.min(N, #self.waypoints)
|
||||
|
||||
|
||||
-- Waypoints.
|
||||
local waypoints={}
|
||||
|
||||
for i=n, #self.waypoints do
|
||||
for i=n, N do
|
||||
|
||||
-- Waypoint.
|
||||
local wp=UTILS.DeepCopy(self.waypoints[i]) --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||
@ -956,7 +960,8 @@ function NAVYGROUP:onafterTurnIntoWindOver(From, Event, To, IntoWindData)
|
||||
-- ID of current waypoint.
|
||||
local uid=self:GetWaypointCurrent().uid
|
||||
|
||||
self:AddWaypoint(self.intowind.Coordinate, self:GetSpeedCruise(), uid)
|
||||
-- Add temp waypoint.
|
||||
local wp=self:AddWaypoint(self.intowind.Coordinate, self:GetSpeedCruise(), uid) ; wp.temp=true
|
||||
|
||||
else
|
||||
|
||||
@ -966,11 +971,11 @@ function NAVYGROUP:onafterTurnIntoWindOver(From, Event, To, IntoWindData)
|
||||
|
||||
-- Next waypoint index and speed.
|
||||
local indx=self:GetWaypointIndexNext()
|
||||
local speed=self:GetWaypointSpeed(indx)
|
||||
local speed=self:GetSpeedToWaypoint(indx)
|
||||
|
||||
-- Update route.
|
||||
self:T(self.lid..string.format("FF Turn Into Wind Over ==> Next WP Index=%d at %.1f knots via update route!", indx, speed))
|
||||
self:__UpdateRoute(-1, indx, speed)
|
||||
self:__UpdateRoute(-1, indx, nil, speed)
|
||||
|
||||
end
|
||||
|
||||
@ -1018,7 +1023,7 @@ function NAVYGROUP:onafterCruise(From, Event, To, Speed)
|
||||
-- No set depth.
|
||||
self.depth=nil
|
||||
|
||||
self:__UpdateRoute(-1, nil, Speed)
|
||||
self:__UpdateRoute(-1, nil, nil, Speed)
|
||||
|
||||
end
|
||||
|
||||
@ -1037,7 +1042,7 @@ function NAVYGROUP:onafterDive(From, Event, To, Depth, Speed)
|
||||
|
||||
self.depth=Depth
|
||||
|
||||
self:__UpdateRoute(-1, nil, Speed)
|
||||
self:__UpdateRoute(-1, nil, nil, Speed)
|
||||
|
||||
end
|
||||
|
||||
@ -1051,7 +1056,7 @@ function NAVYGROUP:onafterSurface(From, Event, To, Speed)
|
||||
|
||||
self.depth=0
|
||||
|
||||
self:__UpdateRoute(-1, nil, Speed)
|
||||
self:__UpdateRoute(-1, nil, nil, Speed)
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -2411,7 +2411,7 @@ function OPSGROUP:GetSpeedToWaypoint(indx)
|
||||
|
||||
local speed=self:GetWaypointSpeed(indx)
|
||||
|
||||
if speed<=0.1 then
|
||||
if speed<=0.01 then
|
||||
speed=self:GetSpeedCruise()
|
||||
end
|
||||
|
||||
@ -4333,6 +4333,10 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
||||
end
|
||||
|
||||
if task and task.dcstask.id=="PatrolZone" then
|
||||
|
||||
---
|
||||
-- SPECIAL TASK: Patrol Zone
|
||||
---
|
||||
|
||||
-- Remove old waypoint.
|
||||
self:RemoveWaypointByID(Waypoint.uid)
|
||||
@ -4360,6 +4364,10 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
||||
wp.missionUID=mission and mission.auftragsnummer or nil
|
||||
|
||||
elseif task and task.dcstask.id=="ReconMission" then
|
||||
|
||||
---
|
||||
-- SPECIAL TASK: Recon Mission
|
||||
---
|
||||
|
||||
local target=task.dcstask.params.target --Ops.Target#TARGET
|
||||
|
||||
@ -4412,7 +4420,7 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
||||
end
|
||||
|
||||
-- Final zone reached ==> task done.
|
||||
self:TaskDone(task)
|
||||
self:TaskDone(task)
|
||||
|
||||
end
|
||||
|
||||
@ -4431,24 +4439,41 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
||||
-- Final waypoint reached?
|
||||
if wpindex==nil or wpindex==#self.waypoints then
|
||||
|
||||
-- Set switch to true.
|
||||
-- Ad infinitum?
|
||||
if self.adinfinitum then
|
||||
|
||||
---
|
||||
-- Ad Infinitum and last waypoint reached.
|
||||
---
|
||||
|
||||
if #self.waypoints<=1 then
|
||||
-- Only one waypoint. Ad infinitum does not really make sense. However, another waypoint could be added later...
|
||||
self:_PassedFinalWaypoint(true, "PassingWaypoint: adinfinitum but only ONE WAYPOINT left")
|
||||
else
|
||||
local uid=self:GetWaypointID(1)
|
||||
self:GotoWaypoint(uid)
|
||||
end
|
||||
else
|
||||
self:_PassedFinalWaypoint(true, "PassingWaypoint: wpindex=nil or wpindex=#self.waypoints")
|
||||
end
|
||||
|
||||
-- Looks like the passing waypoint function is triggered over and over again if the group is near the final waypoint.
|
||||
-- So the only good solution is to guide the group away from that waypoint and then update the route.
|
||||
|
||||
-- Get first waypoint.
|
||||
local wp1=self:GetWaypointByIndex(1)
|
||||
|
||||
-- Get a waypoint
|
||||
local Coordinate=Waypoint.coordinate:GetIntermediateCoordinate(wp1.coordinate, 0.1)
|
||||
|
||||
-- Detour to the temp waypoint. When reached, the normal route is resumed.
|
||||
self:Detour(Coordinate, self.speedCruise, nil, true)
|
||||
|
||||
end
|
||||
else
|
||||
-- Final waypoint reached.
|
||||
self:_PassedFinalWaypoint(true, "PassingWaypoint: wpindex=#self.waypoints (or wpindex=nil)")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Passing mission waypoint?
|
||||
if Waypoint.missionUID then
|
||||
self:T(self.lid.."FF passing mission waypoint")
|
||||
--self:RemoveWaypointByID(Waypoint.uid)
|
||||
end
|
||||
|
||||
-- Check if all tasks/mission are done?
|
||||
@ -4537,7 +4562,7 @@ function OPSGROUP:onafterPassedFinalWaypoint(From, Event, To)
|
||||
self:T(self.lid..string.format("Group passed final waypoint"))
|
||||
|
||||
-- Check if group is done? No tasks mission running.
|
||||
self:_CheckGroupDone()
|
||||
--self:_CheckGroupDone()
|
||||
|
||||
end
|
||||
|
||||
@ -4547,28 +4572,22 @@ end
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
-- @param #number UID The goto waypoint unique ID.
|
||||
function OPSGROUP:onafterGotoWaypoint(From, Event, To, UID)
|
||||
-- @param #number Speed (Optional) Speed to waypoint in knots.
|
||||
function OPSGROUP:onafterGotoWaypoint(From, Event, To, UID, Speed)
|
||||
|
||||
local n=self:GetWaypointIndex(UID)
|
||||
|
||||
if n then
|
||||
|
||||
-- TODO: Switch to re-enable waypoint tasks?
|
||||
if false then
|
||||
local tasks=self:GetTasksWaypoint(n)
|
||||
|
||||
for _,_task in pairs(tasks) do
|
||||
local task=_task --#OPSGROUP.Task
|
||||
task.status=OPSGROUP.TaskStatus.SCHEDULED
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local Speed=self:GetSpeedToWaypoint(n)
|
||||
|
||||
-- Speed to waypoint.
|
||||
Speed=Speed or self:GetSpeedToWaypoint(n)
|
||||
|
||||
-- Debug message
|
||||
self:T(self.lid..string.format("Goto Waypoint UID=%d index=%d from %d at speed %.1f knots", UID, n, self.currentwp, Speed))
|
||||
|
||||
-- Update the route.
|
||||
self:__UpdateRoute(-1, n, Speed)
|
||||
|
||||
self:__UpdateRoute(-0.01, n, nil, Speed)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -6826,16 +6845,7 @@ function OPSGROUP:onafterTransport(From, Event, To)
|
||||
else
|
||||
|
||||
-- Coord where the carrier goes to unload.
|
||||
local Coordinate=nil --Core.Point#COORDINATE
|
||||
|
||||
if self.cargoTransport.carrierGroup and self.cargoTransport.carrierGroup:IsLoading() then
|
||||
--TODO: What the heck is self.cargoTransport.carrierGroup and where is this set?!
|
||||
-- Coordinate of the new carrier.
|
||||
Coordinate=self.cargoTransport.carrierGroup:GetCoordinate()
|
||||
else
|
||||
-- Get a random coordinate in the deploy zone and let the carrier go there.
|
||||
Coordinate=Zone:GetRandomCoordinate()
|
||||
end
|
||||
local Coordinate=Zone:GetRandomCoordinate() --Core.Point#COORDINATE
|
||||
|
||||
-- Add waypoint.
|
||||
if self:IsFlightgroup() then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user