@@ -74,6 +74,7 @@ function AITurn:init(vehicle, driveStrategy, ppc, proximityController, turnConte
7474 self .state = self .states .INITIALIZING
7575 self .name = name or ' AITurn'
7676 self .blocked = false
77+ self .hasChainedAttachments = AIUtil .hasChainedAttachments (self .vehicle )
7778end
7879
7980function AITurn :addState (state )
@@ -233,7 +234,7 @@ function AITurn:getDriveData(dt)
233234 local maxSpeed = self :getForwardSpeed ()
234235 local gx , gz , moveForwards
235236 if self .state == self .states .INITIALIZING then
236- local rowFinishingCourse = self .turnContext :createFinishingRowCourse (self .vehicle )
237+ local rowFinishingCourse = self .turnContext :createFinishingRowCourse (self .vehicle , self : getRaiseImplementNode () )
237238 self .ppc :setCourse (rowFinishingCourse )
238239 self .ppc :initialize (1 )
239240 self .state = self .states .FINISHING_ROW
@@ -276,10 +277,17 @@ function AITurn:setRaiseLowerNodes()
276277 -- in headland corners, we want to stay on the field as much as possible to avoid hitting obstacles around the field.
277278 local _ , backMarkerDistance = self .driveStrategy :getFrontAndBackMarkers ()
278279 if backMarkerDistance < 0 then
279- -- implement on the back of the vehicle, so before the corner, we don't work all the way to the field edge,
280- -- stop a work width before it, then make the turn, back up until the implement reaches the field edge,
281- -- lower, and continue on the new headland direction
282- return self .turnContext .workEndNode , self .turnContext .workStartNode
280+ if self .hasChainedAttachments then
281+ -- implements on the back of the vehicle, we'll make a loop turn forward only, so before the corner,
282+ -- we work all the way to the headland pass edge and then make a 270 turn to continue after the corner.
283+ return self .turnContext .workEndNode , self .turnContext .workStartNode
284+
285+ else
286+ -- implement on the back of the vehicle, so before the corner, we don't work all the way to the field edge,
287+ -- stop a work width before it, then make the turn, back up until the implement reaches the field edge,
288+ -- lower, and continue on the new headland direction
289+ return self .turnContext .workEndNode , self .turnContext .workStartNode
290+ end
283291 else
284292 -- implement on the front of the vehicle, so we can work all the way to the field edge, then make the turn
285293 -- and back up only until the implement reaches the already worked part, work width from the field edge
@@ -734,10 +742,14 @@ end
734742function CourseTurn :generateCalculatedTurn ()
735743 local turnManeuver
736744 if self .turnContext :isHeadlandCorner () then
737- -- TODO_22
738745 self :debug (' This is a headland turn' )
739- turnManeuver = HeadlandCornerTurnManeuver (self .vehicle , self .turnContext , self .vehicle :getAIDirectionNode (),
746+ if self .hasChainedAttachments then
747+ turnManeuver = LoopTurnManeuver (self .vehicle , self .turnContext , self .vehicle :getAIDirectionNode (),
748+ self .turningRadius , self .workWidth , self .steeringLength )
749+ else
750+ turnManeuver = HeadlandCornerTurnManeuver (self .vehicle , self .turnContext , self .vehicle :getAIDirectionNode (),
740751 self .turningRadius , self .workWidth , self .reversingImplement , self .steeringLength )
752+ end
741753 -- adjust turn course for tight turns only for headland corners by default
742754 self .forceTightTurnOffset = self .steeringLength > 0
743755 else
@@ -1006,13 +1018,13 @@ function StartRowOnly:init(vehicle, driveStrategy, ppc, turnContext, startRowCou
10061018 -- implements are now lowering, maneuver ends when they are completely lowered
10071019 self :addState (' IMPLEMENTS_LOWERING' )
10081020 self .vehicle = vehicle
1009- self .settings = vehicle :getCpSettings ()
10101021 self .workStartHandler = WorkStartHandler (vehicle , driveStrategy , turnContext )
1022+ self .settings = vehicle :getCpSettings ()
10111023 self .turningRadius = AIUtil .getTurningRadius (self .vehicle )
1012- --- @type AIDriveStrategyFieldWorkCourse
1013- self .driveStrategy = driveStrategy
10141024 --- @type PurePursuitController
10151025 self .ppc = ppc
1026+ --- @type AIDriveStrategyFieldWorkCourse
1027+ self .driveStrategy = driveStrategy
10161028 --- @type TurnContext
10171029 self .turnContext = turnContext
10181030 self .name = ' StartRowOnly'
0 commit comments