@@ -550,19 +550,24 @@ end
550550--- Use pathfinder to next waypoint
551551---- -------------------------------------------------------------------------------------------------------------------
552552function AIDriveStrategyFieldWorkCourse :startPathfindingToNextWaypoint (ix )
553- self :debug (' start pathfinding to waypoint %d' , ix + 1 )
553+ local targetIx = ix + 1
554+ self :debug (' start pathfinding to waypoint %d' , targetIx )
555+ if self .fieldWorkCourse :isHeadlandTurnAtIx (targetIx + 1 ) then
556+ self :debug (' waypoint after the next is headland turn, skip next and find path to the headland corner at waypoint %d' , targetIx + 1 )
557+ targetIx = targetIx + 1
558+ end
554559 local fm , bm = self :getFrontAndBackMarkers ()
555- self .turnContext = RowStartOrFinishContext (self .vehicle , self .fieldWorkCourse , ix + 1 , ix + 1 ,
560+ self .turnContext = RowStartOrFinishContext (self .vehicle , self .fieldWorkCourse , targetIx , targetIx ,
556561 self .turnNodes , self :getWorkWidth (), fm , bm , self :getTurnEndSideOffset (false ), self :getTurnEndForwardOffset ())
557562 local _ , steeringLength = AIUtil .getSteeringParameters (self .vehicle )
558563 local targetNode , zOffset = self .turnContext :getTurnEndNodeAndOffsets (steeringLength )
559564 local context = PathfinderContext (self .vehicle )
560565 :allowReverse (self :getAllowReversePathfinding ())
561566 :ignoreFruit (not self .settings .avoidFruit :getValue ())
562- self .waypointToContinueOnFailedPathfinding = ix + 1
567+ self .waypointToContinueOnFailedPathfinding = targetIx
563568 self .pathfinderController :registerListeners (self , self .onPathfindingDoneToNextWaypoint ,
564569 self .onPathfindingFailedToNextWaypoint )
565- self :debug (' Start pathfinding to target waypoint %d, zOffset %.1f' , ix + 1 , zOffset )
570+ self :debug (' Start pathfinding to target waypoint %d, zOffset %.1f' , targetIx , zOffset )
566571 self .state = self .states .WAITING_FOR_PATHFINDER
567572 -- to have a course set while waiting for the pathfinder
568573 self :startCourse (self .fieldWorkCourse , self .waypointToContinueOnFailedPathfinding )
0 commit comments