Skip to content

Commit 902a577

Browse files
author
Peter Vaiko
committed
feat: loop turn
Add headland turn maneuver to make corners with a 270 turn. This is good for rigs that can't reverse but there is plenty of room on the field to make a 270 loop. Examples are seed drills with a seed cart. The first headland should be round, the second and the rest can have a corner and there, this 270 will be used. Such rigs are currently auto-detected but we can also make it an option. #737
1 parent 12ff044 commit 902a577

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

scripts/ai/turns/AITurn.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,14 +744,16 @@ function CourseTurn:generateCalculatedTurn()
744744
if self.turnContext:isHeadlandCorner() then
745745
self:debug('This is a headland turn')
746746
if self.hasChainedAttachments then
747+
-- do a 270° turn forward only
747748
turnManeuver = LoopTurnManeuver(self.vehicle, self.turnContext, self.vehicle:getAIDirectionNode(),
748749
self.turningRadius, self.workWidth, self.steeringLength)
750+
self.enableTightTurnOffset = true
749751
else
750752
turnManeuver = HeadlandCornerTurnManeuver(self.vehicle, self.turnContext, self.vehicle:getAIDirectionNode(),
751753
self.turningRadius, self.workWidth, self.reversingImplement, self.steeringLength)
754+
-- adjust turn course for tight turns only for headland corners by default
755+
self.forceTightTurnOffset = self.steeringLength > 0
752756
end
753-
-- adjust turn course for tight turns only for headland corners by default
754-
self.forceTightTurnOffset = self.steeringLength > 0
755757
else
756758
local distanceToFieldEdge = self.turnContext:getDistanceToFieldEdge(self.vehicle:getAIDirectionNode())
757759
local turnOnField = self.driveStrategy:isTurnOnFieldActive()

scripts/ai/turns/TurnManeuver.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ function DubinsTurnManeuver:findAnalyticPath(startNode, startXOffset, startZOffs
459459
return Course.createFromAnalyticPath(self.vehicle, path, true)
460460
end
461461

462+
--- Headland turn maneuver to make corners with a 270 turn. This is good for rigs that can't reverse but there is
463+
--- plenty of room on the field to make a 270 loop. Examples are seed drills with a seed cart. The first headland
464+
--- should be round, the second and the rest can have a corner and there, this 270 will be used.
462465
---@class LoopTurnManeuver : TurnManeuver
463466
LoopTurnManeuver = CpObject(DubinsTurnManeuver)
464467
function LoopTurnManeuver:init(vehicle, turnContext, vehicleDirectionNode, turningRadius,
@@ -468,14 +471,18 @@ function LoopTurnManeuver:init(vehicle, turnContext, vehicleDirectionNode, turni
468471
workWidth, steeringLength)
469472
local turnEndNode, endZOffset = self.turnContext:getTurnEndNodeAndOffsets(steeringLength)
470473
self:debug('r=%.1f, w=%.1f, steeringLength=%.1f, endZOffset=%.1f', turningRadius, workWidth, steeringLength, endZOffset)
474+
-- pull forward a bit to have the implement reach at least the middle of the outgoing edge, so the 270 is
475+
-- easier to turn into the target direction. May need to increase it depending on user feedback.
471476
local pullForward = 0.5 * workWidth
472477
self.course = Course.createFromNode(self.vehicle, vehicleDirectionNode,
473478
0, 0, pullForward, 1, false)
474479
local path = PathfinderUtil.findAnalyticPath(PathfinderUtil.dubinsSolver,
475480
vehicleDirectionNode, 0, pullForward + 0.5, turnEndNode, 0, -steeringLength, turningRadius)
476481
self.course:append(Course.createFromAnalyticPath(self.vehicle, path, true))
482+
TurnManeuver.setLowerImplements(self.course, steeringLength, true)
483+
self:applyTightTurnOffsetToAnalyticPath(self.course)
477484
local endingTurnLength = self.turnContext:appendEndingTurnCourse(self.course, steeringLength)
478-
self:applyTightTurnOffset(endingTurnLength)
485+
TurnManeuver.setLowerImplements(self.course, endingTurnLength, true)
479486
end
480487

481488
-- This is an experiment to create turns with towed implements that better align with the next row.

0 commit comments

Comments
 (0)