mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Waypoints
This commit is contained in:
parent
af023c1994
commit
ec809085b4
@ -141,22 +141,30 @@ end
|
|||||||
-- @param #ASTAR.Node nodeB
|
-- @param #ASTAR.Node nodeB
|
||||||
function ASTAR.LoS(nodeA, nodeB)
|
function ASTAR.LoS(nodeA, nodeB)
|
||||||
|
|
||||||
local los=nodeA.coordinate:IsLOS(nodeB.coordinate, 0.5)
|
local offset=0.1
|
||||||
|
|
||||||
|
local dx=200
|
||||||
|
local dy=dx
|
||||||
|
|
||||||
|
local cA=nodeA.coordinate:SetAltitude(0, true)
|
||||||
|
local cB=nodeB.coordinate:SetAltitude(0, true)
|
||||||
|
|
||||||
|
local los=cA:IsLOS(cB, offset)
|
||||||
|
|
||||||
if los then
|
if los then
|
||||||
local heading=nodeA.coordinate:HeadingTo(nodeB.coordinate)
|
local heading=cA:HeadingTo(cB)
|
||||||
|
|
||||||
local Ap=nodeA.coordinate:Translate(100, heading+90)
|
local Ap=cA:Translate(dx, heading+90)
|
||||||
local Bp=nodeA.coordinate:Translate(100, heading+90)
|
local Bp=cB:Translate(dx, heading+90)
|
||||||
|
|
||||||
los=Ap:IsLOS(Bp, 0.5)
|
los=Ap:IsLOS(Bp, offset)
|
||||||
|
|
||||||
if los then
|
if los then
|
||||||
|
|
||||||
local Am=nodeA.coordinate:Translate(100, heading-90)
|
local Am=cA:Translate(dy, heading-90)
|
||||||
local Bm=nodeA.coordinate:Translate(100, heading-90)
|
local Bm=cB:Translate(dy, heading-90)
|
||||||
|
|
||||||
los=Am:IsLOS(Bm, 0.5)
|
los=Am:IsLOS(Bm, offset)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -170,8 +178,9 @@ end
|
|||||||
|
|
||||||
--- Find the closest node from a given coordinate.
|
--- Find the closest node from a given coordinate.
|
||||||
-- @param #ASTAR self
|
-- @param #ASTAR self
|
||||||
-- @param Core.Point#COORDINATE Coordinate.
|
-- @param #number DeltaX Increment in the direction of start to end coordinate in meters. Default 2000 meters.
|
||||||
-- @return #ASTAR.Node Cloest node to the coordinate.
|
-- @param #number DeltaY Increment perpendicular to the direction of start to end coordinate in meters. Default is same as DeltaX.
|
||||||
|
-- @return #ASTAR self
|
||||||
function ASTAR:CreateGrid()
|
function ASTAR:CreateGrid()
|
||||||
|
|
||||||
local Dx=20000
|
local Dx=20000
|
||||||
@ -218,6 +227,7 @@ function ASTAR:CreateGrid()
|
|||||||
end
|
end
|
||||||
env.info("FF Done building grid!")
|
env.info("FF Done building grid!")
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Find the closest node from a given coordinate.
|
--- Find the closest node from a given coordinate.
|
||||||
|
|||||||
@ -1699,7 +1699,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
|||||||
local speed=self.group and self.group:GetVelocityKMH() or 100
|
local speed=self.group and self.group:GetVelocityKMH() or 100
|
||||||
|
|
||||||
-- Set current waypoint or we get problem that the _PassingWaypoint function is triggered too early, i.e. right now and not when passing the next WP.
|
-- Set current waypoint or we get problem that the _PassingWaypoint function is triggered too early, i.e. right now and not when passing the next WP.
|
||||||
local current=self.group:GetCoordinate():WaypointAir("BARO", COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, speed, true, nil, {}, "Current")
|
local current=self.group:GetCoordinate():WaypointAir(COORDINATE.WaypointAltType.BARO, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, speed, true, nil, {}, "Current")
|
||||||
table.insert(wp, current)
|
table.insert(wp, current)
|
||||||
|
|
||||||
-- Add remaining waypoints to route.
|
-- Add remaining waypoints to route.
|
||||||
@ -1710,7 +1710,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n)
|
|||||||
-- Debug info.
|
-- Debug info.
|
||||||
local hb=self.homebase and self.homebase:GetName() or "unknown"
|
local hb=self.homebase and self.homebase:GetName() or "unknown"
|
||||||
local db=self.destbase and self.destbase:GetName() or "unknown"
|
local db=self.destbase and self.destbase:GetName() or "unknown"
|
||||||
self:T(self.lid..string.format("Updating route for WP #%d-%d homebase=%s destination=%s", n, #wp, hb, db))
|
self:I(self.lid..string.format("Updating route for WP #%d-%d homebase=%s destination=%s", n, #wp, hb, db))
|
||||||
|
|
||||||
|
|
||||||
if #wp>1 then
|
if #wp>1 then
|
||||||
@ -2910,15 +2910,26 @@ end
|
|||||||
|
|
||||||
--- Initialize Mission Editor waypoints.
|
--- Initialize Mission Editor waypoints.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @param #table waypoints Table of waypoints. Default is from group template.
|
|
||||||
-- @return #FLIGHTGROUP self
|
-- @return #FLIGHTGROUP self
|
||||||
function FLIGHTGROUP:InitWaypoints(waypoints)
|
function FLIGHTGROUP:InitWaypoints()
|
||||||
|
|
||||||
-- Template waypoints.
|
-- Template waypoints.
|
||||||
self.waypoints0=self.group:GetTemplateRoutePoints()
|
self.waypoints0=self.group:GetTemplateRoutePoints()
|
||||||
|
|
||||||
-- Waypoints of group as defined in the ME.
|
self:I(self.waypoints0)
|
||||||
self.waypoints=waypoints or UTILS.DeepCopy(self.waypoints0)
|
|
||||||
|
-- Waypoints
|
||||||
|
self.waypoints={}
|
||||||
|
|
||||||
|
for index,wp in pairs(self.waypoints0) do
|
||||||
|
|
||||||
|
env.info("FF index "..index)
|
||||||
|
|
||||||
|
local waypoint=self:_CreateWaypoint(wp)
|
||||||
|
|
||||||
|
self:_AddWaypoint(waypoint)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-- Get home and destination airbases from waypoints.
|
-- Get home and destination airbases from waypoints.
|
||||||
self.homebase=self.homebase or self:GetHomebaseFromWaypoints()
|
self.homebase=self.homebase or self:GetHomebaseFromWaypoints()
|
||||||
|
|||||||
@ -539,7 +539,7 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
|
|||||||
|
|
||||||
-- Add remaining waypoints to route.
|
-- Add remaining waypoints to route.
|
||||||
for i=n, #self.waypoints do
|
for i=n, #self.waypoints do
|
||||||
local wp=self.waypoints[i]
|
local wp=self.waypoints[i] --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
|
|
||||||
-- Set speed.
|
-- Set speed.
|
||||||
if i==n then
|
if i==n then
|
||||||
|
|||||||
@ -2185,24 +2185,17 @@ end
|
|||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param #table waypoint DCS waypoint data table.
|
-- @param #table waypoint DCS waypoint data table.
|
||||||
-- @return #OPSGROUP.Waypoint Waypoint data.
|
-- @return #OPSGROUP.Waypoint Waypoint data.
|
||||||
function OPSGROUP:_CreateWaypoint(waypoint)
|
function OPSGROUP:_CreateWaypoint(waypoint, detour, onroad, formation)
|
||||||
|
|
||||||
local wp={} --#OPSGROUP.Waypoint
|
waypoint.uid=self.wpcounter
|
||||||
|
waypoint.coordinate=COORDINATE:New(waypoint.x, waypoint.alt, waypoint.y)
|
||||||
wp.wp=waypoint
|
waypoint.detour=detour and detour or false
|
||||||
wp.uid=self.wpcounter
|
waypoint.formation=formation
|
||||||
|
waypoint.onroad=onroad and onroad or false
|
||||||
wp.altitude=altitude
|
|
||||||
wp.speed=speed
|
|
||||||
wp.detour=detour
|
|
||||||
wp.formation=formation
|
|
||||||
wp.onroad=onroad
|
|
||||||
|
|
||||||
wp.coordinate=coordinate
|
|
||||||
|
|
||||||
self.wpcounter=self.wpcounter+1
|
self.wpcounter=self.wpcounter+1
|
||||||
|
|
||||||
return wp
|
return waypoint
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Initialize Mission Editor waypoints.
|
--- Initialize Mission Editor waypoints.
|
||||||
@ -2213,16 +2206,17 @@ function OPSGROUP:_AddWaypoint(waypoint, wpnumber)
|
|||||||
|
|
||||||
wpnumber=wpnumber or #self.waypoints+1
|
wpnumber=wpnumber or #self.waypoints+1
|
||||||
|
|
||||||
|
env.info(string.format("adding waypoint at index=%d", wpnumber))
|
||||||
|
|
||||||
-- Add waypoint to table.
|
-- Add waypoint to table.
|
||||||
tabel.insert(self.waypoints, wpnumber, waypoint)
|
table.insert(self.waypoints, wpnumber, waypoint)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Initialize Mission Editor waypoints.
|
--- Initialize Mission Editor waypoints.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param #table waypoints Table of waypoints. Default is from group template.
|
|
||||||
-- @return #OPSGROUP self
|
-- @return #OPSGROUP self
|
||||||
function OPSGROUP:InitWaypoints(waypoints)
|
function OPSGROUP:InitWaypoints()
|
||||||
|
|
||||||
-- Template waypoints.
|
-- Template waypoints.
|
||||||
self.waypoints0=self.group:GetTemplateRoutePoints()
|
self.waypoints0=self.group:GetTemplateRoutePoints()
|
||||||
@ -2232,11 +2226,10 @@ function OPSGROUP:InitWaypoints(waypoints)
|
|||||||
|
|
||||||
for index,wp in pairs(self.waypoints0) do
|
for index,wp in pairs(self.waypoints0) do
|
||||||
|
|
||||||
local waypoint=self:_CreateWaypoint()
|
local waypoint=self:_CreateWaypoint(wp)
|
||||||
|
|
||||||
self:_AddWaypoint(waypoint)
|
self:_AddWaypoint(waypoint)
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
@ -2319,7 +2312,7 @@ function OPSGROUP:_UpdateWaypointTasks(n)
|
|||||||
table.insert(taskswp, TaskPassingWaypoint)
|
table.insert(taskswp, TaskPassingWaypoint)
|
||||||
|
|
||||||
-- Waypoint task combo.
|
-- Waypoint task combo.
|
||||||
wp.wp.task=self.group:TaskCombo(taskswp)
|
wp.task=self.group:TaskCombo(taskswp)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user