diff --git a/AIDriver.lua b/AIDriver.lua index 9db3784f0..785fb2d79 100644 --- a/AIDriver.lua +++ b/AIDriver.lua @@ -1193,10 +1193,11 @@ function AIDriver:dischargeAtUnloadPoint(dt,unloadPointIx) local _,_,z = worldToLocal(tipRefpoint, uX,uY,uZ); z = courseplay:isNodeTurnedWrongWay(vehicle,tipRefpoint)and -z or z - local foundHeap = self:checkForHeapBehindMe(tipper) + local foundHeap, fillLevel = self:checkForHeapBehindMe(tipper) --when we reached the unload point, stop the tractor and inhibit any action from ppc till the trailer is empty - if (foundHeap or z >= 0) and tipper.cp.fillLevel ~= 0 or tipper:getTipState() ~= Trailer.TIPSTATE_CLOSED then + --check the heap is at least a specific size and not just a mote, so that the tipper can add to the pile a little bit instead of being so far forward + if ((foundHeap and fillLevel > 2000) or z >= 0) and tipper.cp.fillLevel ~= 0 or tipper:getTipState() ~= Trailer.TIPSTATE_CLOSED then stopForTipping = true readyToDischarge = true end @@ -1216,8 +1217,8 @@ function AIDriver:dischargeAtUnloadPoint(dt,unloadPointIx) self.pullForward = false end - self:debugSparse('foundHeap(%s) z(%s) readyToDischarge(%s) isTipping(%s) pullForward(%s)', - tostring(foundHeap), tostring(z), tostring(readyToDischarge), tostring(isTipping), tostring(self.pullForward)) + self:debugSparse('foundHeap(%s) heapSize(%s) z(%s) readyToDischarge(%s) isTipping(%s) pullForward(%s)', + tostring(foundHeap), tostring(fillLevel), tostring(z), tostring(readyToDischarge), tostring(isTipping), tostring(self.pullForward)) --ready with tipping, go forward on the course if tipper.cp.fillLevel == 0 then @@ -1269,16 +1270,18 @@ function AIDriver:dischargeAtUnloadPoint(dt,unloadPointIx) end function AIDriver:checkForHeapBehindMe(tipper) - local dischargeNode = tipper:getCurrentDischargeNode().node - local offset = -self.settings.loadUnloadOffsetZ:get() - offset = courseplay:isNodeTurnedWrongWay(self.vehicle,dischargeNode)and -offset or offset - local startX,startY,startZ = localToWorld(dischargeNode,0,0,offset) ; - local tempHeightX,tempHeightY,tempHeightZ = localToWorld(dischargeNode,0,0,offset+0.5) - local searchWidth = 1 - local fillType = DensityMapHeightUtil.getFillTypeAtLine(startX,startY,startZ,tempHeightX,tempHeightY,tempHeightZ, searchWidth) - if fillType == tipper.cp.fillType then - return true; - end + local dischargeNode = tipper:getCurrentDischargeNode().node + local offset = -self.settings.loadUnloadOffsetZ:get() + offset = courseplay:isNodeTurnedWrongWay(self.vehicle,dischargeNode)and -offset or offset + local startX,startY,startZ = localToWorld(dischargeNode,0,0,offset) ; + local tempHeightX,tempHeightY,tempHeightZ = localToWorld(dischargeNode,0,0,offset+0.5) + local searchWidth = 1 + local fillType = DensityMapHeightUtil.getFillTypeAtLine(startX,startY,startZ,tempHeightX,tempHeightY,tempHeightZ, searchWidth) + if fillType == tipper.cp.fillType then + local fillLevel = DensityMapHeightUtil.getFillLevelAtArea(fillType,startX,startZ,startX,startZ+1,startX+1,startZ) --should represent an area of 1m^2 starting at the discharge node + return true,fillLevel + end + return false,0 end --only bga, else triggerHandler handles discharge! diff --git a/BunkerSiloAIDriver.lua b/BunkerSiloAIDriver.lua index 8e35c8f5c..baa52c605 100644 --- a/BunkerSiloAIDriver.lua +++ b/BunkerSiloAIDriver.lua @@ -231,7 +231,7 @@ function BunkerSiloAIDriver:getDriveIntoSiloCourse(targetColumn) local driveDirection = self:isDriveDirectionReverse() local numLines = self.bunkerSiloManager:getNumberOfLines() local x,z = self.bunkerSiloManager:getSiloPartPosition(1,targetColumn) - local dx,dz = self.bunkerSiloManager:getSiloPartPosition(numLines,targetColumn) + local dx,dz = self.bunkerSiloManager:getSiloPartPosition(numLines - 1,targetColumn) --stop a little bit shy of the end to prevent pushing chaff out of open-end bunker local startOffset = -5 local course = Course.createFromTwoWorldPositions(self.vehicle, x, z, dx, dz, 0, startOffset, 0, 5, driveDirection) local firstWpIx