Skip to content

Commit be0be69

Browse files
author
Peter Vaiko
committed
fix: leaving course after pathfinder track
When CP uses the pathfinder for a connecting track and there is a headland turn with more than 90 degrees right after the connecting track, won't move the relevant waypoint past the corner as the corner waypoint heading points "backwards" (>90). Make sure that when resuming from the StartRowOnly turn, if there is no waypoint in front of the vehicle, use the one after the turn end wp in the context. This will still skip the turn maneuver but at least the driver will continue the course. #881
1 parent 1942434 commit be0be69

2 files changed

Lines changed: 5 additions & 14 deletions

File tree

scripts/ai/PurePursuitController.lua

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -603,18 +603,6 @@ function PurePursuitController:isReversing()
603603
end
604604
end
605605

606-
function PurePursuitController:getDirection(lz)
607-
local ctx, cty, ctz = self:getClosestWaypointData()
608-
if not ctx then
609-
return lz
610-
end
611-
local dx, _, dz = worldToLocal(self.controlledNode, ctx, cty, ctz)
612-
local distance = math.sqrt(dx * dx + dz * dz)
613-
local r = distance * distance / 2 / dx
614-
local steeringAngle = math.atan(self.vehicle.cp.distances.frontWheelToRearWheel / r)
615-
return math.cos(steeringAngle)
616-
end
617-
618606
-- goal point local position in the vehicle's coordinate system
619607
function PurePursuitController:getGoalPointLocalPosition()
620608
return localToLocal(self.goalWpNode.node, self.controlledNode, 0, 0, 0)

scripts/ai/strategies/AIDriveStrategyFieldWorkCourse.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,12 @@ function AIDriveStrategyFieldWorkCourse:resumeFieldworkAfterTurn(ix)
411411
self.ppc:setNormalLookaheadDistance()
412412
self:startWaitingForLower()
413413
self:lowerImplements()
414-
local startIx = self.fieldWorkCourse:getNextFwdWaypointIxFromVehiclePosition(ix,
414+
local startIx, found = self.fieldWorkCourse:getNextFwdWaypointIxFromVehiclePosition(ix,
415415
self.vehicle:getAIDirectionNode(), self.workWidth / 2)
416-
self:startCourse(self.fieldWorkCourse, startIx)
416+
-- if we can't found a waypoint in front of us, just use the next (ix would be the turn end, this is after that)
417+
-- ix may be problematic, especially if the next waypoint is a headland corner with > 90 degrees angle, PPC
418+
-- may never advance to the next waypoint
419+
self:startCourse(self.fieldWorkCourse, found and startIx or ix + 1)
417420
end
418421

419422
--- Attempt to recover from a turn where the vehicle got blocked. This replaces the current turn with a

0 commit comments

Comments
 (0)