mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Navygroup
This commit is contained in:
@@ -617,65 +617,43 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
|
|||||||
-- Waypoints.
|
-- Waypoints.
|
||||||
local waypoints={}
|
local waypoints={}
|
||||||
|
|
||||||
-- Add remaining waypoints to route.
|
-- Waypoint.
|
||||||
local depth=nil
|
local wp=UTILS.DeepCopy(self.waypoints[n]) --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
for i=n, #self.waypoints do
|
|
||||||
|
|
||||||
-- Waypoint.
|
|
||||||
local wp=UTILS.DeepCopy(self.waypoints[i]) --Ops.OpsGroup#OPSGROUP.Waypoint
|
|
||||||
|
|
||||||
-- Check if next wp.
|
|
||||||
if i==n then
|
|
||||||
|
|
||||||
-- Speed.
|
-- Speed.
|
||||||
if Speed then
|
if Speed then
|
||||||
-- Take speed specified.
|
-- Take speed specified.
|
||||||
wp.speed=UTILS.KnotsToMps(Speed)
|
wp.speed=UTILS.KnotsToMps(Speed)
|
||||||
else
|
else
|
||||||
-- Take default waypoint speed. But make sure speed>0 if patrol ad infinitum.
|
-- Take default waypoint speed. But make sure speed>0 if patrol ad infinitum.
|
||||||
if self.adinfinitum and wp.speed<0.1 then
|
if self.adinfinitum and wp.speed<0.1 then
|
||||||
wp.speed=UTILS.KmphToMps(self.speedCruise)
|
wp.speed=UTILS.KmphToMps(self.speedCruise)
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if Depth then
|
|
||||||
wp.alt=-Depth
|
|
||||||
elseif self.depth then
|
|
||||||
wp.alt=-self.depth
|
|
||||||
else
|
|
||||||
-- Take default waypoint alt.
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Current set speed in m/s.
|
|
||||||
self.speedWp=wp.speed
|
|
||||||
|
|
||||||
-- Current set depth.
|
|
||||||
depth=wp.alt
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
-- Dive depth is applied to all other waypoints.
|
|
||||||
if self.depth then
|
|
||||||
wp.alt=-self.depth
|
|
||||||
else
|
|
||||||
-- Take default waypoint depth.
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add waypoint.
|
|
||||||
table.insert(waypoints, wp)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Depth then
|
||||||
|
wp.alt=-Depth
|
||||||
|
elseif self.depth then
|
||||||
|
wp.alt=-self.depth
|
||||||
|
else
|
||||||
|
-- Take default waypoint alt.
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Current set speed in m/s.
|
||||||
|
self.speedWp=wp.speed
|
||||||
|
|
||||||
|
-- Add waypoint.
|
||||||
|
table.insert(waypoints, wp)
|
||||||
|
|
||||||
-- Current waypoint.
|
-- Current waypoint.
|
||||||
local current=self:GetCoordinate():WaypointNaval(UTILS.MpsToKmph(self.speedWp), depth)
|
local current=self:GetCoordinate():WaypointNaval(UTILS.MpsToKmph(self.speedWp), wp.alt)
|
||||||
table.insert(waypoints, 1, current)
|
table.insert(waypoints, 1, current)
|
||||||
|
|
||||||
|
|
||||||
if #waypoints>1 then
|
if #waypoints>1 then
|
||||||
|
|
||||||
self:T(self.lid..string.format("Updateing route: WP %d-->%d-->%d (#%d), Speed=%.1f knots, Depth=%d m",
|
self:T(self.lid..string.format("Updateing route: WP %d-->%d-->%d (#%d), Speed=%.1f knots, Depth=%d m",
|
||||||
self.currentwp, n, #self.waypoints, #waypoints-1, UTILS.MpsToKnots(self.speedWp), depth))
|
self.currentwp, n, #self.waypoints, #waypoints-1, UTILS.MpsToKnots(self.speedWp), wp.alt))
|
||||||
|
|
||||||
|
|
||||||
-- Route group to all defined waypoints remaining.
|
-- Route group to all defined waypoints remaining.
|
||||||
|
|||||||
@@ -2682,10 +2682,10 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if all tasks/mission are done? If so, RTB or WAIT.
|
-- Check if all tasks/mission are done?
|
||||||
-- Note, we delay it for a second to let the OnAfterPassingwaypoint function to be executed in case someone wants to add another waypoint there.
|
-- Note, we delay it for a second to let the OnAfterPassingwaypoint function to be executed in case someone wants to add another waypoint there.
|
||||||
if ntasks==0 then
|
if ntasks==0 then
|
||||||
self:_CheckGroupDone()
|
self:_CheckGroupDone(0.1)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
@@ -3061,23 +3061,34 @@ function OPSGROUP:_CheckGroupDone(delay)
|
|||||||
self:ScheduleOnce(delay, self._CheckGroupDone, self)
|
self:ScheduleOnce(delay, self._CheckGroupDone, self)
|
||||||
else
|
else
|
||||||
|
|
||||||
|
local waypoint=self:GetWaypoint(self.currentwp)
|
||||||
|
|
||||||
|
local n=self:GetTasksWaypoint(id)
|
||||||
|
|
||||||
|
|
||||||
if self.adinfinitum then
|
if self.adinfinitum then
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Parol Ad Infinitum
|
-- Parol Ad Infinitum
|
||||||
---
|
---
|
||||||
|
|
||||||
|
if #self.waypoints>0 then
|
||||||
|
|
||||||
-- Next waypoint index.
|
-- Next waypoint index.
|
||||||
local i=self:GetWaypointIndexNext(true)
|
local i=self:GetWaypointIndexNext(true)
|
||||||
|
|
||||||
-- Get positive speed to first waypoint.
|
-- Get positive speed to first waypoint.
|
||||||
local speed=self:GetSpeedToWaypoint(i)
|
local speed=self:GetSpeedToWaypoint(i)
|
||||||
|
|
||||||
-- Start route at first waypoint.
|
-- Start route at first waypoint.
|
||||||
self:UpdateRoute(i, speed)
|
self:UpdateRoute(i, speed)
|
||||||
|
|
||||||
self:T(self.lid..string.format("Adinfinitum=TRUE ==> Goto WP index=%d at speed=%d knots", i, speed))
|
self:T(self.lid..string.format("Adinfinitum=TRUE ==> Goto WP index=%d at speed=%d knots", i, speed))
|
||||||
|
|
||||||
|
else
|
||||||
|
self:E(self.lid..string.format("WARNING: No waypoints left! Commanding a Full Stop"))
|
||||||
|
self:__FullStop(-1)
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user