@@ -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.5 ) 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,17 +552,18 @@ 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+ setWorldRotation (self .unloadPositionNode , 0 , yRot - math.pi / 2 , 0 )
538556 else
539557 local x , y , z = localToWorld (trailer .rootNode , - math.abs (distShovelDirectionNode ) - self .distShovelTrailerPreUnload , 0 , 0 )
540558 setTranslation (self .unloadPositionNode , x , y , z )
541- setRotation (self .unloadPositionNode , 0 , MathUtil . getValidLimit ( yRot + math.pi / 2 ) , 0 )
559+ setWorldRotation (self .unloadPositionNode , 0 , yRot + math.pi / 2 , 0 )
542560 end
543561 if trailer [" spec_pdlc_goeweilPack.balerStationary" ] or trailer .size .length < 4 then
544562 --- Goeweil needs to be approached from behind
563+ self :debug (" Approaching the trailer from behind." )
545564 local x , y , z = localToWorld (trailer .rootNode , 0 , 0 , - math.abs (distShovelDirectionNode ) - distRootNodeToExactFillRootNode - self .distShovelTrailerPreUnload )
546565 setTranslation (self .unloadPositionNode , x , y , z )
547- setRotation (self .unloadPositionNode , 0 , yRot , 0 )
566+ setWorldRotation (self .unloadPositionNode , 0 , yRot , 0 )
548567 end
549568 self :startPathfindingToTrailer ()
550569end
0 commit comments