From 89c4c96df3158528d99c21c2c112ece1a2b0848c Mon Sep 17 00:00:00 2001 From: Peter Vaiko Date: Sat, 26 Mar 2022 08:46:42 -0400 Subject: [PATCH] Headland -> up/down transition fix Do not skip a turn on connecting track if the turn starts at the end of the connecting track leading into the first up/down row. --- scripts/Course.lua | 3 ++- scripts/ai/AIDriveStrategyFieldWorkCourse.lua | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/Course.lua b/scripts/Course.lua index 7415846c3..035f65d50 100644 --- a/scripts/Course.lua +++ b/scripts/Course.lua @@ -624,7 +624,8 @@ end --- How far are we from the waypoint marked as the beginning of the up/down rows? ---@param ix number start searching from this index. Will stop searching after 100 m ----@return number of meters or math.huge if no start up/down row waypoint found within 100 meters and the index of the first up/down waypoint +---@return number, number of meters or math.huge if no start up/down row waypoint found within 100 meters and the +--- index of the first up/down waypoint function Course:getDistanceToFirstUpDownRowWaypoint(ix) local d = 0 local isConnectingTrack = false diff --git a/scripts/ai/AIDriveStrategyFieldWorkCourse.lua b/scripts/ai/AIDriveStrategyFieldWorkCourse.lua index 10b04f80c..3dd339ce6 100644 --- a/scripts/ai/AIDriveStrategyFieldWorkCourse.lua +++ b/scripts/ai/AIDriveStrategyFieldWorkCourse.lua @@ -391,6 +391,11 @@ function AIDriveStrategyFieldWorkCourse:onWaypointChange(ix, course) self:debug('connecting track ended, back to work, first lowering implements.') self.state = self.states.WORKING self:lowerImplements() + elseif self.course:isTurnStartAtIx(ix) and + not self.course:isOnConnectingTrack(ix + 1) and + not self.course:isOnHeadland(ix + 1)then + self:debug('ending connecting track with a turn into the up/down rows') + self:startTurn(ix) end elseif self.state == self.states.WORKING then -- towards the end of the field course make sure the implement reaches the last waypoint