Skip to content

Commit

Permalink
6.01.00199 Combine pocket fix
Browse files Browse the repository at this point in the history
Make sure the combine starts the pocket early enough so it has the tank
capacity to finish the pocket.
  • Loading branch information
pvaiko committed Apr 28, 2019
1 parent f7f841f commit 09d5894
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
18 changes: 14 additions & 4 deletions CombineAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function CombineAIDriver:onWaypointPassed(ix)
self:checkFruit()
-- make sure we start making a pocket while we still have some fill capacity left as we'll be
-- harvesting fruit while making the pocket
if not self.fieldOnLeft then
if self:shouldMakePocket() then
self.fillLevelFullPercentage = self.pocketFillLevelFullPercentage
end
self:checkDistanceUntilFull(ix)
Expand Down Expand Up @@ -91,8 +91,8 @@ function CombineAIDriver:changeToFieldworkUnloadOrRefill()
if self.vehicle.cp.realisticDriving then
self:checkFruit()
-- TODO: check around turn maneuvers we may not want to pull back before a turn
if not self.fieldOnLeft or (self.fruitLeft > 0.75 and self.fruitRight > 0.75) then
-- I'm on the edge of the field, make a pocket on the right side and wait there for the unload
if self:shouldMakePocket() then
-- I'm on the edge of the field or fruit is on both sides, make a pocket on the right side and wait there for the unload
local pocketCourse, nextIx = self:createPocketCourse()
if pocketCourse then
self:debug('No room to the left, making a pocket for unload')
Expand All @@ -105,7 +105,7 @@ function CombineAIDriver:changeToFieldworkUnloadOrRefill()
-- revert to normal behavior
UnloadableFieldworkAIDriver.changeToFieldworkUnloadOrRefill(self)
end
elseif self.fruitLeft > self.fruitRight then
elseif self:shouldPullBack() then
-- is our pipe in the fruit? (assuming pipe is on the left side)
local pullBackCourse = self:createPullBackCourse()
if pullBackCourse then
Expand Down Expand Up @@ -211,6 +211,16 @@ function CombineAIDriver:unloadFinished()
return (self:allFillLevelsOk() and not discharging) or fillLevel < 0.1
end

function CombineAIDriver:shouldMakePocket()
-- on the outermost headland clockwise (field edge) or fruit both sides
return not self.fieldOnLeft or (self.fruitLeft > 0.75 and self.fruitRight > 0.75)
end

function CombineAIDriver:shouldPullBack()
-- is our pipe in the fruit? (assuming pipe is on the left side)
return self.fruitLeft > self.fruitRight
end

function CombineAIDriver:checkFruit()
-- getValidityOfTurnDirections() wants to have the vehicle.aiDriveDirection, so get that here.
local dx,_,dz = localDirectionToWorld(self.vehicle:getAIVehicleDirectionNode(), 0, 0, 1)
Expand Down
2 changes: 1 addition & 1 deletion modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<modDesc descVersion="40">
<version>6.01.00198</version>
<version>6.01.00199</version>
<author><![CDATA[Courseplay.devTeam]]></author>
<title>
<br>CoursePlay SIX</br>
Expand Down
3 changes: 2 additions & 1 deletion turn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ function courseplay:turn(vehicle, dt, turnContext)
-- We have more waypoints, so we goto stage 4, which will still change waypoints together with checking if we can lower the implement
vehicle.cp.turnStage = 4;
end;
courseplay:debug(string.format("%s:(Turn) Ending turn, stage %d", nameNum(vehicle), vehicle.cp.turnStage ), 14);
courseplay:debug(string.format("%s:(Turn) Ending turn at waypoint %d, stage %d", nameNum(vehicle), vehicle.cp.curTurnIndex, vehicle.cp.turnStage ), 14);
return;
end;

Expand Down Expand Up @@ -1401,6 +1401,7 @@ function courseplay:generateTurnTypeForward3PointTurn(vehicle, turnInfo)
fromPoint.z = z;
toPoint.x, _, toPoint.z = localToWorld(turnInfo.targetNode, 0, 0, turnInfo.directionNodeToTurnNodeLength - turnInfo.zOffset + 5);
courseplay:generateTurnStraightPoints(vehicle, stopDir, toPoint, false, true);
courseplay.setLowerImplementsPoint(vehicle, turnInfo.frontMarker, turnInfo.targetNode)
else
--- Get the 2 circle center coordinate
local center1ZOffset = turnInfo.targetDeltaZ + turnInfo.zOffset + frontOffset;
Expand Down

0 comments on commit 09d5894

Please sign in to comment.