Skip to content

Commit d2345b4

Browse files
authored
Merge pull request #884 from Courseplay/881-headland-turn-right-after-pathfinder-course
fix: leaving course after pathfinder track
2 parents 1942434 + be0be69 commit d2345b4

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)