Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
mode 9/10 fixes and very basic seed calculator (#6700)
Browse files Browse the repository at this point in the history
* mode 9/10 fixes and very basic seed calculator

- improves mode 10 fillup and compacting
- fixes a lua errors mode 10
- fixes mode 9 unloading at trailer bugs
- added a very basic seed calculator with field size
- small adjustment to mode 4 loading at waitpoint

* PR fixes
  • Loading branch information
schwiti6190 authored Jan 21, 2021
1 parent 2a1a7f2 commit 8266b52
Show file tree
Hide file tree
Showing 26 changed files with 352 additions and 117 deletions.
34 changes: 21 additions & 13 deletions BunkersiloManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,22 @@ widthNode --> | | <-- startNode (sx,_,sz)
---@param vehicle vehicle
---@param Silo BunkerSilo or simulated HeapSilo
---@param float workwidth
---@param implement relevant workTool
---@param node targetNode is either the front/back node of the implement used to check if the bestTarget was passed
---@param boolean is the silo a heap ?
function BunkerSiloManager:init(vehicle, Silo, width, object,isHeap)
function BunkerSiloManager:init(vehicle, Silo, width, targetNode,isHeap)
print("BunkerSiloManager: init()")
self.siloMap = self:createBunkerSiloMap(vehicle, Silo, width,isHeap)
self.silo = Silo
self.vehicle = vehicle
self.object = object
self.targetNode = targetNode
end

function BunkerSiloManager:getSiloMap()
return self.siloMap
end

function BunkerSiloManager:getSilo()
return self.silo
end

---creating the relevant siloMap
Expand Down Expand Up @@ -262,7 +270,7 @@ function BunkerSiloManager:isAtEnd(bestTarget)
local targetUnit = self.siloMap[bestTarget.line][bestTarget.column]
local cx ,cz = targetUnit.cx, targetUnit.cz
local cy = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, cx, 1, cz);
local x,y,z = getWorldTranslation(self.object.rootNode)
local x,y,z = getWorldTranslation(self.targetNode)
local distance2Target = courseplay:distance(x,z, cx, cz) --distance from shovel to target
if distance2Target < 1 then
if bestTarget.line == #self.siloMap then
Expand Down Expand Up @@ -297,21 +305,21 @@ function BunkerSiloManager:getBestTargetFillUnitFillUp(bestTarget)
end
if column == #line and mostFillLevelAtLine > 0 then
fillingTarget = {
line = lineIndex;
column = mostFillLevelIndex;
empty = false;
}
line = lineIndex;
column = mostFillLevelIndex;
empty = false;
}
stopSearching = true
break
end
end
end
if mostFillLevelAtLine == 0 then
fillingTarget = {
line = 1;
column = 1;
empty = true;
}
line = 1;
column = 1;
empty = true;
}
end

bestTarget = fillingTarget
Expand All @@ -335,7 +343,7 @@ function BunkerSiloManager:updateTarget(bestTarget)
local targetUnit = self.siloMap[bestTarget.line][bestTarget.column]
local cx ,cz = targetUnit.cx, targetUnit.cz
local cy = getTerrainHeightAtWorldPos(g_currentMission.terrainRootNode, cx, 1, cz);
local x,y,z = getWorldTranslation(self.object.rootNode)
local x,y,z = getWorldTranslation(self.targetNode)
local distance2Target = courseplay:distance(x,z, cx, cz) --distance from shovel to target
if math.abs(distance2Target) < 1 then
bestTarget.line = math.min(bestTarget.line + 1, #self.siloMap)
Expand Down
3 changes: 2 additions & 1 deletion FillableFieldworkAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ function FillableFieldworkAIDriver:driveUnloadOrRefill()
else
self:clearInfoText('NO_SELECTED_FILLTYPE')
end
local isNearWaitPoint, waitPointIx = self.course:hasWaitPointWithinDistance(self.ppc:getRelevantWaypointIx(), 10)
local isNearWaitPoint, waitPointIx = self.course:hasWaitPointWithinDistance(self.ppc:getRelevantWaypointIx(), 25)
--this one is used to disable loading at the unloading stations,
--might be better to disable the triggerID for loading
self:enableFillTypeLoading(isNearWaitPoint)
if self.course:isTemporary() then
-- use the courseplay speed limit until we get to the actual unload corse fields (on alignment/temporary)
self:setSpeed(self.vehicle.cp.speeds.field)
elseif self.refillState == self.states.TO_BE_REFILLED and isNearWaitPoint then
-- should be reworked and be similar to mode 1 loading at start
local distanceToWait = self.course:getDistanceBetweenVehicleAndWaypoint(self.vehicle, waitPointIx)
self:setSpeed(MathUtil.clamp(distanceToWait,self.vehicle.cp.speeds.crawl,self:getRecordedSpeed()))
if distanceToWait < 1 then
Expand Down
Loading

0 comments on commit 8266b52

Please sign in to comment.