mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Update ArmyGroup.lua
- Improved updateroute waypoints
This commit is contained in:
parent
d031651b58
commit
00f8fccfae
@ -775,8 +775,8 @@ function ARMYGROUP:Status()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Info text.
|
-- Info text.
|
||||||
local text=string.format("%s [%d/%d]: ROE/AS=%d/%d | T/M=%d/%d | Wp=%d[%d]-->%d[%d]/%d [%s] | Life=%.1f | v=%.1f (%d) | Hdg=%03d | Ammo=%d | Detect=%s | Cargo=%.1f",
|
local text=string.format("%s [%d/%d]: ROE/AS=%d/%d | T/M=%d/%d | Wp=%d[%d]-->%d[%d]/%d [%s] | Life=%.1f | v=%.1f (%d) [%s] | Hdg=%03d | Ammo=%d | Detect=%s | Cargo=%.1f",
|
||||||
fsmstate, nelem, Nelem, roe, als, nTaskTot, nMissions, wpidxCurr, wpuidCurr, wpidxNext, wpuidNext, wpN, wpF, life, speed, speedEx, hdg, ammo, ndetected, cargo)
|
fsmstate, nelem, Nelem, roe, als, nTaskTot, nMissions, wpidxCurr, wpuidCurr, wpidxNext, wpuidNext, wpN, wpF, life, speed, speedEx, formation, hdg, ammo, ndetected, cargo)
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1083,20 +1083,24 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
|||||||
-- Formation at the current position.
|
-- Formation at the current position.
|
||||||
local formation0=wp.action
|
local formation0=wp.action
|
||||||
if formation0==ENUMS.Formation.Vehicle.OnRoad then
|
if formation0==ENUMS.Formation.Vehicle.OnRoad then
|
||||||
if wp.roadcoord then
|
-- Next waypoint is on road. Check if we are already on road.
|
||||||
if wp.roaddist>10 then
|
if roaddist>10 then
|
||||||
formation0=ENUMS.Formation.Vehicle.OffRoad
|
-- Currently off road ==> we add an on road WP later.
|
||||||
end
|
|
||||||
else
|
|
||||||
formation0=ENUMS.Formation.Vehicle.OffRoad
|
formation0=ENUMS.Formation.Vehicle.OffRoad
|
||||||
|
else
|
||||||
|
-- Already on road. We won't add an extra on road WP.
|
||||||
|
formation0=ENUMS.Formation.Vehicle.OnRoad
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Debug
|
||||||
|
--env.info(self.lid.."FF formation0="..tostring(formation0))
|
||||||
|
|
||||||
-- Current point.
|
-- Current point.
|
||||||
local current=coordinate:WaypointGround(UTILS.MpsToKmph(self.speedWp), formation0) --ENUMS.Formation.Vehicle.OffRoad)
|
local current=coordinate:WaypointGround(UTILS.MpsToKmph(self.speedWp), formation0)
|
||||||
table.insert(waypoints, 1, current)
|
table.insert(waypoints, 1, current)
|
||||||
|
|
||||||
-- Check if route consists of more than one waypoint.
|
-- Check if route consists of more than one waypoint (otherwise we have no previous waypoint)
|
||||||
if N-n>0 then
|
if N-n>0 then
|
||||||
|
|
||||||
-- Loop over waypoints.
|
-- Loop over waypoints.
|
||||||
@ -1110,7 +1114,7 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
|||||||
i=self.currentwp
|
i=self.currentwp
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Next waypoint.
|
-- Next waypoint. We create a copy because we need to modify it.
|
||||||
local wp=UTILS.DeepCopy(self.waypoints[j]) --Ops.OpsGroup#OPSGROUP.Waypoint
|
local wp=UTILS.DeepCopy(self.waypoints[j]) --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
|
|
||||||
-- Previous waypoint. Index is i and not i-1 because we added the current position.
|
-- Previous waypoint. Index is i and not i-1 because we added the current position.
|
||||||
@ -1145,6 +1149,9 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
|||||||
-- Add "On Road" waypoint in between.
|
-- Add "On Road" waypoint in between.
|
||||||
local wproad=wp0.roadcoord:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
|
local wproad=wp0.roadcoord:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
|
|
||||||
|
-- Debug
|
||||||
|
--wp0.roadcoord:MarkToAll(self.lid.." Added road wp near "..tostring(wproad.action))
|
||||||
|
|
||||||
-- Insert road waypoint.
|
-- Insert road waypoint.
|
||||||
table.insert(waypoints, wproad)
|
table.insert(waypoints, wproad)
|
||||||
end
|
end
|
||||||
@ -1158,10 +1165,15 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
|||||||
-- Add "On Road" waypoint in between.
|
-- Add "On Road" waypoint in between.
|
||||||
local wproad=wp.roadcoord:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
|
local wproad=wp.roadcoord:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
|
|
||||||
|
-- Debug
|
||||||
|
--wp.roadcoord:MarkToAll(self.lid.." Added road wp far "..tostring(wproad.action))
|
||||||
|
|
||||||
-- Insert road waypoint.
|
-- Insert road waypoint.
|
||||||
table.insert(waypoints, wproad)
|
table.insert(waypoints, wproad)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Debug
|
||||||
|
--wp.coordinate:MarkToAll(self.lid.." Added wp actual"..tostring(wp.action))
|
||||||
|
|
||||||
-- Add waypoint.
|
-- Add waypoint.
|
||||||
table.insert(waypoints, wp)
|
table.insert(waypoints, wp)
|
||||||
@ -1200,6 +1212,9 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
|||||||
-- Add "On Road" waypoint in between.
|
-- Add "On Road" waypoint in between.
|
||||||
local wproad=coordRoad:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
|
local wproad=coordRoad:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
|
|
||||||
|
-- Debug
|
||||||
|
--coordRoad:MarkToAll(self.lid.." Added road wp near "..tostring(wp.action))
|
||||||
|
|
||||||
-- Insert road waypoint.
|
-- Insert road waypoint.
|
||||||
table.insert(waypoints, wproad)
|
table.insert(waypoints, wproad)
|
||||||
|
|
||||||
@ -1210,6 +1225,9 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
|||||||
-- Add "On Road" waypoint in between.
|
-- Add "On Road" waypoint in between.
|
||||||
local wproad=wp.roadcoord:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
|
local wproad=wp.roadcoord:WaypointGround(UTILS.MpsToKmph(wp.speed), ENUMS.Formation.Vehicle.OnRoad) --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
|
|
||||||
|
-- Debug
|
||||||
|
--wp.roadcoord:MarkToAll(self.lid.." Added road wp far "..tostring(wp.action))
|
||||||
|
|
||||||
-- Insert road waypoint.
|
-- Insert road waypoint.
|
||||||
table.insert(waypoints, wproad)
|
table.insert(waypoints, wproad)
|
||||||
|
|
||||||
@ -1217,6 +1235,14 @@ function ARMYGROUP:onafterUpdateRoute(From, Event, To, n, N, Speed, Formation)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Waypoint set set to on-road but lies off-road. We set it to off-road. the on-road wp has been inserted.
|
||||||
|
if wp.action==ENUMS.Formation.Vehicle.OnRoad and wp.roaddist>10 then
|
||||||
|
wp.action=ENUMS.Formation.Vehicle.OffRoad
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Debug
|
||||||
|
--wp.coordinate:MarkToAll(self.lid.." Added coord "..tostring(wp.action))
|
||||||
|
|
||||||
-- Add actual waypoint.
|
-- Add actual waypoint.
|
||||||
table.insert(waypoints, wp)
|
table.insert(waypoints, wp)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user