@@ -86,6 +86,7 @@ function AIDriveStrategyShovelSiloLoader:init(task, job)
8686 AIDriveStrategyCourse .initStates (self , AIDriveStrategyShovelSiloLoader .myStates )
8787 self .state = self .states .INITIAL
8888 self .debugChannel = CpDebug .DBG_SILO
89+ self .unloadPositionNode = CpUtil .createNode (" unloadPositionNode" , 0 , 0 , 0 )
8990 return self
9091end
9192
@@ -126,7 +127,6 @@ function AIDriveStrategyShovelSiloLoader:startWithoutCourse(jobParameters)
126127 self :startCourse (self .course , 1 )
127128
128129 self .jobParameters = jobParameters
129- self .unloadPositionNode = CpUtil .createNode (" unloadPositionNode" , 0 , 0 , 0 )
130130
131131 --- Is the unload target a trailer?
132132 self .isUnloadingAtTrailerActive = jobParameters .unloadAt :getValue () == CpSiloLoaderJobParameters .UNLOAD_TRAILER
@@ -330,26 +330,44 @@ function AIDriveStrategyShovelSiloLoader:getDriveData(dt, vX, vY, vZ)
330330 end
331331 elseif self .state == self .states .DRIVING_TO_UNLOAD then
332332 self :setMaxSpeed (self .settings .reverseSpeed :getValue ())
333- local refNode
333+ local refNode , margin = nil , 0
334334 if self .isUnloadingAtTrailerActive then
335335 refNode = self .targetTrailer .exactFillRootNode
336+ --- Applies a small offset, so we don't overshoot the trailer center.
337+ margin = self .shovelController :isHighDumpShovel () and 1 or 0
336338 else
337339 refNode = self .unloadTrigger :getFillUnitExactFillRootNode (1 )
338340 end
339- if self .shovelController :isShovelOverTrailer (refNode ) then
341+ if self .shovelController :isShovelOverTrailer (refNode , margin ) then
340342 self :setNewState (self .states .UNLOADING )
341343 self :setMaxSpeed (0 )
342344 end
343345 if not self .isUnloadingAtTrailerActive then
344- if self .shovelController :isShovelOverTrailer (refNode , 3 ) and self .shovelController :canDischarge (self .unloadTrigger ) then
346+ if self .shovelController :isShovelOverTrailer (refNode , 3 ) and
347+ self .shovelController :canDischarge (self .unloadTrigger ) then
348+
345349 self :setNewState (self .states .UNLOADING )
346350 self :setMaxSpeed (0 )
347351 end
348352 end
349353 elseif self .state == self .states .UNLOADING then
350- self :setMaxSpeed (0 )
351354 if self :hasFinishedUnloading () then
352355 self :startReversingAwayFromUnloading ()
356+ self :setMaxSpeed (0 )
357+ else
358+ if self .shovelController :isHighDumpShovel () and
359+ not self .shovelController :isDischarging () then
360+ --- Makes sure we move slightly forwards,
361+ --- as the high dump offset might not work for
362+ --- unloading of the complete shovel.
363+ if self .shovelController :isShovelOverTrailer (
364+ self .targetTrailer .exactFillRootNode , 0 ) then
365+
366+ self :setMaxSpeed (0 )
367+ end
368+ else
369+ self :setMaxSpeed (0 )
370+ end
353371 end
354372 elseif self .state == self .states .REVERSING_AWAY_FROM_UNLOAD then
355373 self :setMaxSpeed (self .settings .fieldSpeed :getValue ())
@@ -534,14 +552,17 @@ function AIDriveStrategyShovelSiloLoader:searchForTrailerToUnloadInto()
534552 if dx > 0 then
535553 local x , y , z = localToWorld (trailer .rootNode , math.abs (distShovelDirectionNode ) + self .distShovelTrailerPreUnload , 0 , 0 )
536554 setTranslation (self .unloadPositionNode , x , y , z )
537- setRotation (self .unloadPositionNode , 0 , MathUtil .getValidLimit (yRot - math.pi / 2 ), 0 )
555+ dirX , dirZ = MathUtil .getDirectionFromYRotation (yRot - math.pi / 2 )
556+ setDirection (self .unloadPositionNode , dirX , 0 , dirZ )
538557 else
539558 local x , y , z = localToWorld (trailer .rootNode , - math.abs (distShovelDirectionNode ) - self .distShovelTrailerPreUnload , 0 , 0 )
540559 setTranslation (self .unloadPositionNode , x , y , z )
541- setRotation (self .unloadPositionNode , 0 , MathUtil .getValidLimit (yRot + math.pi / 2 ), 0 )
560+ dirX , dirZ = MathUtil .getDirectionFromYRotation (yRot + math.pi / 2 )
561+ setDirection (self .unloadPositionNode , dirX , 0 , dirZ )
542562 end
543563 if trailer [" spec_pdlc_goeweilPack.balerStationary" ] or trailer .size .length < 4 then
544564 --- Goeweil needs to be approached from behind
565+ self :debug (" Approaching the trailer from behind." )
545566 local x , y , z = localToWorld (trailer .rootNode , 0 , 0 , - math.abs (distShovelDirectionNode ) - distRootNodeToExactFillRootNode - self .distShovelTrailerPreUnload )
546567 setTranslation (self .unloadPositionNode , x , y , z )
547568 setRotation (self .unloadPositionNode , 0 , yRot , 0 )
0 commit comments