From 03ab81e380dad09c80e24a250a32ff8b0cca0225 Mon Sep 17 00:00:00 2001 From: MddMBorg Date: Wed, 30 Jun 2021 14:13:41 +0100 Subject: [PATCH 1/2] Modified the SiloDriver to drive back less to prevent pushing chaff out of bunker as much with shield. Added a check for a reverse-discharging driver to check the size of the heap, to make it drive over existing heaps a little bit before dumping. --- AIDriver.lua | 17 ++++++++++++++--- BunkerSiloAIDriver.lua | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/AIDriver.lua b/AIDriver.lua index ee86c00f3..07fa443d0 100644 --- a/AIDriver.lua +++ b/AIDriver.lua @@ -1193,9 +1193,11 @@ function AIDriver:dischargeAtUnloadPoint(dt,unloadPointIx) z = courseplay:isNodeTurnedWrongWay(vehicle,tipRefpoint)and -z or z local foundHeap = self:checkForHeapBehindMe(tipper) + local fillLevel = self:getHeapSizeBehindMe(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 @@ -1215,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 @@ -1280,6 +1282,15 @@ function AIDriver:checkForHeapBehindMe(tipper) end end +function AIDriver:getHeapSizeBehindMe(tipper) + local dischargeNode = tipper:getCurrentDischargeNode().node + local offset = -self.settings.loadUnloadOffsetZ:get() + offset = courseplay:isNodeTurnedWrongWay(self.vehicle,dischargeNode)and -offset or offset + local startX,_,startZ = localToWorld(dischargeNode,0,0,offset) + fillLevel = DensityMapHeightUtil.getFillLevelAtArea(tipper.cp.fillType,startX,startZ,startX,startZ+1,startX+1,startZ) --should represent an area of 1m^2 starting at the discharge node + return fillLevel +end + --only bga, else triggerHandler handles discharge! function AIDriver:dischargeAtTipTrigger(dt) local trigger = self.vehicle.cp.currentTipTrigger 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 From da2ab6f6b4b7e2f63dbf13beaa2d0ad35c7b878a Mon Sep 17 00:00:00 2001 From: MddMBorg Date: Fri, 2 Jul 2021 12:45:09 +0100 Subject: [PATCH 2/2] Feedback for PR, consolidated heap size finding into original checkForHeapBehindMe --- AIDriver.lua | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/AIDriver.lua b/AIDriver.lua index 07fa443d0..4434916fb 100644 --- a/AIDriver.lua +++ b/AIDriver.lua @@ -1192,8 +1192,7 @@ 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 fillLevel = self:getHeapSizeBehindMe(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 --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 @@ -1270,25 +1269,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 -end - -function AIDriver:getHeapSizeBehindMe(tipper) - local dischargeNode = tipper:getCurrentDischargeNode().node - local offset = -self.settings.loadUnloadOffsetZ:get() - offset = courseplay:isNodeTurnedWrongWay(self.vehicle,dischargeNode)and -offset or offset - local startX,_,startZ = localToWorld(dischargeNode,0,0,offset) - fillLevel = DensityMapHeightUtil.getFillLevelAtArea(tipper.cp.fillType,startX,startZ,startX,startZ+1,startX+1,startZ) --should represent an area of 1m^2 starting at the discharge node - return fillLevel + 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!