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

Commit

Permalink
Merge pull request #7320 from MddMBorg/MddMBorg/ChangesForDumpingInSilos
Browse files Browse the repository at this point in the history
Mdd m borg/changes for dumping in silos
  • Loading branch information
schwiti6190 authored Jul 2, 2021
2 parents 3c2d99f + da2ab6f commit 4ab5b9c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
31 changes: 17 additions & 14 deletions AIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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!
Expand Down
2 changes: 1 addition & 1 deletion BunkerSiloAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4ab5b9c

Please sign in to comment.