From 316bb61d0c414dcaf375f9578b44d8663148c648 Mon Sep 17 00:00:00 2001 From: Peter Vaiko Date: Mon, 2 Oct 2023 19:31:21 -0400 Subject: [PATCH] fix: reversing turn When we have to reverse to reach the work start after the turn, only change direction when we actually pass those waypoints marked with CHANGE_DIRECTION_WHEN_ALIGNED instead of checking the current waypoint. This avoids switching the direction (and thus lowering the implement) too early, when temporarily during the turn the implement is aligned with the target row. --- scripts/ai/turns/AITurn.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/ai/turns/AITurn.lua b/scripts/ai/turns/AITurn.lua index 012c5b62b..ffeafcd60 100644 --- a/scripts/ai/turns/AITurn.lua +++ b/scripts/ai/turns/AITurn.lua @@ -637,7 +637,9 @@ end --- change direction as soon as the implement is aligned. --- So check that here and force a direction change when possible. function CourseTurn:changeDirectionWhenAligned() - if TurnManeuver.hasTurnControl(self.turnCourse, self.turnCourse:getCurrentWaypointIx(), TurnManeuver.CHANGE_DIRECTION_WHEN_ALIGNED) then + if self.ppc:getLastPassedWaypointIx() and + TurnManeuver.hasTurnControl(self.turnCourse, self.ppc:getLastPassedWaypointIx(), + TurnManeuver.CHANGE_DIRECTION_WHEN_ALIGNED) then local aligned = self.driveStrategy:areAllImplementsAligned(self.turnContext.turnEndWpNode.node) self:debug('aligned: %s', tostring(aligned)) if aligned then