@@ -559,16 +559,22 @@ ReedsSheppHeadlandTurnManeuver = CpObject(TurnManeuver)
559559--- just after the cutter finished the corner, that is, the harvester should drive forward in the original direction
560560--- until there is no fruit left. It'll then do a quick 90 degree 3 point turn to align with the new direction.
561561function ReedsSheppHeadlandTurnManeuver :init (vehicle , turnContext , vehicleDirectionNode , turningRadius )
562+ self .vehicle = vehicle
562563 local solver = ReedsSheppSolver ()
563564 -- use lateWorkStartNode since we covered the corner in the inbound direction already
564565 local path = PathfinderUtil .findAnalyticPath (solver , vehicleDirectionNode , 0 , 0 ,
565566 turnContext .lateWorkStartNode , 0 , - turnContext .backMarkerDistance , turningRadius )
566567 self .course = Course .createFromAnalyticPath (vehicle , path , true )
567- self .course :adjustForReversing (2 )
568- -- add a little straight section to the end so we have a little buffer and don't end the turn right at
569- -- the work start
570- self .course :extend ((self :getReversingOffset (vehicle , vehicleDirectionNode ) or 4 ) + 1 )
571- TurnManeuver .setLowerImplements (self .course , 5 , true )
568+ self .course :adjustForTowedImplements (2 )
569+ if self .course :endsInReverse () then
570+ -- add a little straight section to the end so we have a little buffer and don't end the turn right at
571+ -- the work start
572+ local reversingOffset = (self :getReversingOffset (vehicle , vehicleDirectionNode ) or 4 )
573+ self :debug (' Extending course by %.1f m' , reversingOffset )
574+ self .course :extend ( reversingOffset + 2 , - turnContext .turnEndWp .dx , - turnContext .turnEndWp .dz )
575+ end
576+ local endingTurnLength = turnContext :appendEndingTurnCourse (self .course , 0 )
577+ TurnManeuver .setLowerImplements (self .course , endingTurnLength , true )
572578end
573579
574580--- @class TurnEndingManeuver : TurnManeuver
0 commit comments