chore: næse mod næse logger positioner og grund pr. maskine (1.62.354)
This commit is contained in:
@@ -66,10 +66,11 @@ end
|
||||
-- så hele sættet er fri. -> {points = {...}, meters} eller nil (ingen fri plads inden MAX_REVERSE_M / sporet slutter)
|
||||
function ADHeadOn.escapePath(start, trail, otherPath, length)
|
||||
local points, meters, prev, clearFor = {}, 0, start, nil
|
||||
if trail == nil or trail[1] == nil then return nil, "intet kørt spor bag den" end
|
||||
for _, p in ipairs(trail or {}) do
|
||||
if p.x == nil or p.z == nil then return nil end
|
||||
if p.x == nil or p.z == nil then return nil, "ugyldigt vejpunkt" end
|
||||
meters = meters + dist(prev, p)
|
||||
if meters > ADHeadOn.MAX_REVERSE_M then return nil end
|
||||
if meters > ADHeadOn.MAX_REVERSE_M then return nil, string.format("ikke fri af den andens rute inden %d m", ADHeadOn.MAX_REVERSE_M) end
|
||||
table.insert(points, p)
|
||||
prev = p
|
||||
if minDistance(p, otherPath or {}) >= ADHeadOn.CLEAR_M then
|
||||
@@ -79,13 +80,13 @@ function ADHeadOn.escapePath(start, trail, otherPath, length)
|
||||
clearFor = nil
|
||||
end
|
||||
end
|
||||
return nil
|
||||
return nil, string.format("sporet bag den slutter efter %.0f m (før den er fri)", meters)
|
||||
end
|
||||
|
||||
-- Spærrer et andet køretøj (positioner {x, z}) bakkevejen?
|
||||
-- Spærrer et andet køretøj (positioner {x, z, name}) bakkevejen? -> true, navn
|
||||
function ADHeadOn.isBlockedBehind(points, others)
|
||||
for _, other in ipairs(others or {}) do
|
||||
if minDistance(other, points) <= ADHeadOn.BEHIND_BLOCK_M then return true end
|
||||
if minDistance(other, points) <= ADHeadOn.BEHIND_BLOCK_M then return true, other.name end
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -173,7 +174,7 @@ local function otherPositions(adEnv, a, b)
|
||||
for _, vehicle in pairs(g_currentMission.vehicleSystem.vehicles or {}) do
|
||||
if not skip[vehicle] and vehicle.rootNode ~= nil then
|
||||
local x, _, z = getWorldTranslation(vehicle.rootNode)
|
||||
table.insert(list, {x = x, z = z})
|
||||
table.insert(list, {x = x, z = z, name = name(vehicle)})
|
||||
end
|
||||
end
|
||||
return list
|
||||
@@ -182,9 +183,12 @@ end
|
||||
local function optionFor(adEnv, vehicle, other, others)
|
||||
local behind = routeOf(vehicle)
|
||||
local _, otherAhead = routeOf(other)
|
||||
local escape = ADHeadOn.escapePath(pose(vehicle), behind, otherAhead, rigLength(adEnv, vehicle) + ADHeadOn.REACHED_SLACK_M)
|
||||
if escape ~= nil and ADHeadOn.isBlockedBehind(escape.points, others) then escape = nil end
|
||||
return {escape = escape, unloading = isUnloading(vehicle)}
|
||||
local escape, why = ADHeadOn.escapePath(pose(vehicle), behind, otherAhead, rigLength(adEnv, vehicle) + ADHeadOn.REACHED_SLACK_M)
|
||||
if escape ~= nil then
|
||||
local blocked, by = ADHeadOn.isBlockedBehind(escape.points, others)
|
||||
if blocked then escape, why = nil, string.format("'%s' holder på bakkevejen", tostring(by)) end
|
||||
end
|
||||
return {escape = escape, unloading = isUnloading(vehicle), why = why}
|
||||
end
|
||||
|
||||
-- Bak ad sporet, vent til den anden er forbi; derefter genoptages AD's opgave (setUp beregner ruten forfra).
|
||||
@@ -342,12 +346,17 @@ local function resolve(adEnv, a, b, now)
|
||||
local optA, optB = optionFor(adEnv, a, b, others), optionFor(adEnv, b, a, others)
|
||||
local pick = ADHeadOn.chooseBacker(optA, optB)
|
||||
if pick == nil then
|
||||
local pa, pb = pose(a), pose(b)
|
||||
Logging.info(ADHeadOn.LOG_PREFIX .. "'%s' (%.0f, %.0f): %s; '%s' (%.0f, %.0f): %s; afstand %.0f m", name(a), pa.x, pa.z,
|
||||
tostring(optA.why), name(b), pb.x, pb.z, tostring(optB.why), dist(pa, pb))
|
||||
giveUp(a, b, "ingen af dem kan bakke fri")
|
||||
return
|
||||
end
|
||||
attempts[key] = {count = (entry ~= nil and entry.count or 0) + 1, at = now}
|
||||
local backer, other, option = a, b, optA
|
||||
if pick == "b" then backer, other, option = b, a, optB end
|
||||
local pa, pb = pose(backer), pose(other)
|
||||
Logging.info(ADHeadOn.LOG_PREFIX .. "valgt til at bakke: '%s' (%.0f, %.0f) for '%s' (%.0f, %.0f), afstand %.0f m", name(backer), pa.x, pa.z, name(other), pb.x, pb.z, dist(pa, pb))
|
||||
interrupt(backer, HeadOnTask.new(adEnv, backer, other, option.escape, key))
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.62.353.0</version>
|
||||
<version>1.62.354.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user