@@ -246,6 +246,7 @@ function AITurn:finishRow(dt)
246246 -- keep driving straight until we need to raise our implements
247247 if self .driveStrategy :shouldRaiseImplements (self :getRaiseImplementNode ()) then
248248 self .driveStrategy :raiseImplements ()
249+ self .driveStrategy :raiseControllerEvent (AIDriveStrategyCourse .onFinishRowEvent , self .turnContext :isHeadlandCorner ())
249250 self :debug (' Row finished, starting turn.' )
250251 self :startTurn ()
251252 end
@@ -307,16 +308,12 @@ end
307308function KTurn :startTurn ()
308309 AITurn .startTurn (self )
309310 self .state = self .states .FORWARD
310- self .vehicle :raiseAIEvent (" onAIFieldWorkerTurnProgress" , " onAIImplementTurnProgress" , 0 , self .turnContext :isLeftTurn ())
311- self :debug (' Turn progress 0' )
312311end
313312
314313function KTurn :turn (dt )
315314 -- we end the K turn with a temporary course leading straight into the next row. During this turn the
316315 -- AI driver's state remains TURNING and thus calls AITurn:drive() which wil take care of raising the implements
317316 local endTurn = function (course )
318- self :debug (' Turn progress 100' )
319- self .vehicle :raiseAIEvent (" onAIFieldWorkerTurnProgress" , " onAIImplementTurnProgress" , 100 , self .turnContext :isLeftTurn ())
320317 self .state = self .states .ENDING_TURN
321318 self .ppc :setCourse (course )
322319 self .ppc :initialize (1 )
@@ -346,7 +343,7 @@ function KTurn:turn(dt)
346343 endTurn (self .endingTurnCourse )
347344 else
348345 -- reverse until we can make turn to the turn end point
349- self .vehicle :raiseAIEvent (" onAIFieldWorkerTurnProgress" , " onAIImplementTurnProgress" , 50 , self .turnContext :isLeftTurn ())
346+ self .vehicle :raiseAIEvent (" onAIFieldWorkerTurnProgress" , " onAIImplementTurnProgress" , 0.5 , self .turnContext :isLeftTurn ())
350347 self :debug (' Turn progress 50' )
351348 self .state = self .states .REVERSE
352349 self .endingTurnCourse = TurnEndingManeuver (self .vehicle , self .turnContext ,
@@ -573,8 +570,6 @@ function CourseTurn:turn()
573570
574571 local gx , gz , moveForwards , maxSpeed = AITurn .turn (self )
575572
576- self :updateTurnProgress ()
577-
578573 self :changeDirectionWhenAligned ()
579574 self :changeToFwdWhenWaypointReached ()
580575
589584--- @return boolean true if it is ok the continue driving , false when the vehicle should stop
590585function CourseTurn :endTurn (dt )
591586 -- keep driving on the turn course until we need to lower our implements
587+ self .driveStrategy :raiseControllerEvent (AIDriveStrategyCourse .onTurnEndProgressEvent ,
588+ self .turnContext .workStartNode , self .turnContext :isLeftTurn ())
592589 local shouldLower , dz = self .driveStrategy :shouldLowerImplements (self .turnContext .workStartNode , self .ppc :isReversing ())
593590 if shouldLower then
594591 if not self .implementsLowered then
@@ -605,7 +602,7 @@ function CourseTurn:endTurn(dt)
605602 -- for those people who set insanely high turn speeds...
606603 local implementCheckDistance = math.max (1 , 0.1 * self .vehicle :getLastSpeed ())
607604 if dz and dz > - implementCheckDistance then
608- if self .vehicle : getCanAIFieldWorkerContinueWork () then
605+ if self .driveStrategy : getCanContinueWork () then
609606 self :debug (" implements lowered, resume fieldwork" )
610607 self :resumeFieldworkAfterTurn (self .turnContext .turnEndWpIx )
611608 else
@@ -620,21 +617,6 @@ function CourseTurn:endTurn(dt)
620617 return true
621618end
622619
623- function CourseTurn :updateTurnProgress ()
624- if self .turnCourse and not self .turnContext :isHeadlandCorner () then
625- -- turn progress is for example rotating plows, no need to worry about that during headland turns
626- local progress = self .turnCourse :getCurrentWaypointIx () / self .turnCourse :getNumberOfWaypoints ()
627- if (progress - (self .lastProgress or 0 )) > 0.1 then
628- -- just send 0 and 1 as it looks like some plows won't turn fully if they receive something in between
629- -- also, start turning a bit before we reach the middle of the turn to make sure it is ready
630- local progressToSend = progress <= 0.3 and 0 or 1
631- self .vehicle :raiseAIEvent (" onAIFieldWorkerTurnProgress" , " onAIImplementTurnProgress" , progressToSend , self .turnContext :isLeftTurn ())
632- self :debug (' progress %.1f (left: %s)' , progressToSend , self .turnContext :isLeftTurn ())
633- self .lastProgress = progress
634- end
635- end
636- end
637-
638620function CourseTurn :onWaypointChange (ix )
639621 AITurn .onWaypointChange (self , ix )
640622 if self .turnCourse then
@@ -967,10 +949,6 @@ function FinishRowOnly:startTurn()
967949 end
968950end
969951
970- function FinishRowOnly :updateTurnProgress ()
971- -- do nothing since this isn't really a turn
972- end
973-
974952--- A turn which really isn't a turn just a course to start a field work row using the supplied course and
975953--- making sure we start working at the start point defined by the turn context with all implements lowered in time.
976954--- This does not actually drive the course like the other AITurn derivates to keep full control in the strategy
@@ -1045,7 +1023,7 @@ function StartRowOnly:getDriveData()
10451023 -- for those people who set insanely high turn speeds...
10461024 local implementCheckDistance = math.max (1 , 0.1 * self .vehicle :getLastSpeed ())
10471025 if dz and dz > - implementCheckDistance then
1048- if self .vehicle : getCanAIFieldWorkerContinueWork () then
1026+ if self .driveStrategy : getCanContinueWork () then
10491027 self :debug (" implements lowered, resume fieldwork" )
10501028 self :resumeFieldworkAfterTurn (self .turnContext .turnEndWpIx )
10511029 else
0 commit comments