@@ -76,10 +76,6 @@ AIDriveStrategyCombineCourse.isAAIDriveStrategyCombineCourse = true
7676function AIDriveStrategyCombineCourse :init (task , job )
7777 AIDriveStrategyFieldWorkCourse .init (self , task , job )
7878 AIDriveStrategyCourse .initStates (self , AIDriveStrategyCombineCourse .myStates )
79- --- Combine needs a field polygon for the self-unload to work. Although it is a user setting, but it can be
80- --- changed during the work, so we always require the field polygon, regardless of the setting, as it is checked
81- --- only after starting the CP driver.
82- self .state = self .states .WAITING_FOR_FIELD_BOUNDARY_DETECTION
8379 self .fruitLeft , self .fruitRight = 0 , 0
8480 self .litersPerMeter = 0
8581 self .litersPerSecond = 0
@@ -243,17 +239,20 @@ function AIDriveStrategyCombineCourse:getDriveData(dt, vX, vY, vZ)
243239 self :setMaxSpeed (0 )
244240 end
245241
246- if self .state == self .states .INITIAL and self .vehicle :cpGetFieldPolygon () == nil then
247- self :setMaxSpeed (0 )
248- self .state = self .states .WAITING_FOR_FIELD_BOUNDARY_DETECTION
242+ --- Combine may need the field polygon for the self-unload to work, so if by now we don't have one
243+ --- and the field boundary detection is not running, start it. This can happen if the combine wasn't started
244+ --- directly, such as as it was driving to the field and then switched strategy
245+ if not self .vehicle :cpIsFieldBoundaryDetectionRunning () and self .vehicle :cpGetFieldPolygon () == nil then
249246 self :startFieldBoundaryDetection ()
250247 end
251248
252- if self .state == self .states .WAITING_FOR_FIELD_BOUNDARY_DETECTION then
253- self :setMaxSpeed (0 )
249+ if self .vehicle :cpIsFieldBoundaryDetectionRunning () then
250+ if self .settings .selfUnload :getValue () then
251+ -- don't have the field boundary yet, and self unload is selected, don't move
252+ self :setMaxSpeed (0 )
253+ end
254254 if self :waitForFieldBoundary () then
255255 self :debug (' Have field boundary now.' )
256- self .state = self .states .INITIAL
257256 end
258257 elseif self .state == self .states .WORKING then
259258 -- Harvesting
0 commit comments