Skip to content

Commit 7eea607

Browse files
antler22claude
andcommitted
Apply pvaiko round-4 review items (1-9, 11, 12)
- Fix debug strings: 'Call grain cart' -> 'manual unloader' (CpAIFieldWorker) - getCombineStrategy(): proxy-first order, remove misleading comment - driveBesideCombine(): update doc comment; use ppc:getNormalLookaheadDistance() getter - PurePursuitController: add getNormalLookaheadDistance() getter - Add AGENTS.md: 'always use getters to access member variables' - setupFollowCourse(): move manual-combine placeholder logic here, use Course.createStraightForwardCourse - startCourseFollowingCombine(): remove now-inlined placeholder block and unused followCourseRefreshTime init - Revert startPathfindingToWaitingCombine to near-upstream (no isManualCombine param/tuning) - Revert call site and onPathfindingDoneToWaitingCombine redirect-timer init - Revert driveToCombine() straight-line redirect block - CollisionAvoidanceController: exclude manual combines from course-intersection check; revert to direct getCpDriveStrategy() call - getDriveData(): disable PPC off-track check unconditionally when manual proxy is active; remove redundant call from unloadMovingCombine Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f149b30 commit 7eea607

5 files changed

Lines changed: 77 additions & 152 deletions

File tree

AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Courseplay Agent Guidelines
2+
3+
## Code Style
4+
5+
- **Always use getters to access member variables.** Do not read fields like `self.ppc.normalLookAheadDistance` directly from outside the owning class; call the appropriate getter instead (e.g. `self.ppc:getNormalLookaheadDistance()`). Add a getter to the class if one does not already exist.

scripts/ai/CollisionAvoidanceController.lua

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,29 @@ end
5858

5959
function CollisionAvoidanceController:findPotentialCollisions()
6060
for _, vehicle in pairs(g_currentMission.vehicleSystem.vehicles) do
61-
if AIDriveStrategyCombineCourse.isActiveCpCombine(vehicle) then
61+
if AIDriveStrategyCombineCourse.isActiveCpCombine(vehicle) and
62+
not (vehicle.cpIsManualCombineCallingUnloader and vehicle:cpIsManualCombineCallingUnloader()) then
6263
local d = calcDistanceFrom(self.vehicle.rootNode, vehicle.rootNode)
6364
if d < self.range then
64-
local otherStrategy = vehicle:getCpDriveStrategy()
65-
if otherStrategy then
66-
local myCourse = self.strategy:getCurrentCourse()
67-
local otherCourse = otherStrategy:getCurrentCourse()
68-
local myDistanceToCollision, otherDistanceToCollision = myCourse:intersects(otherCourse, self.lookahead, true)
69-
if myDistanceToCollision then
70-
-- our course intersects with this vehicle's course (lastSpeedReal is in m/ms)
71-
-- for our own ETE, we always use the field speed and not the actual speed. This is to make sure
72-
-- we come to a full stop on a warning and remain stopped while the warning is active
73-
local myEte = myDistanceToCollision / (self.strategy:getFieldSpeed())
74-
local otherEte = CpMathUtil.divide(otherDistanceToCollision, (vehicle.lastSpeedReal * 1000))
75-
-- self:debug('Checking %s at %.1f m, %.1f, ETE %.1f %.1f', CpUtil.getName(vehicle), d, myDistanceToCollision, myEte, otherEte)
76-
if math.abs(myEte - otherEte) < self.eteDiffThreshold then
77-
if not self.warning:get() or (self.warning:get() and vehicle ~= self.warningVehicle) then
78-
-- no warning is active yet, or there is, but this is a different vehicle
79-
self:debug('collision warning: my course intersects with %s in %.1f m, my ETE %.1f, other ETE %.1f',
80-
CpUtil.getName(vehicle), myDistanceToCollision, myEte, otherEte)
81-
end
82-
self.warningVehicle = vehicle
83-
self.warning:set(true, self.clearWarningDelayMs)
84-
return
65+
local myCourse = self.strategy:getCurrentCourse()
66+
local otherCourse = vehicle:getCpDriveStrategy():getCurrentCourse()
67+
local myDistanceToCollision, otherDistanceToCollision = myCourse:intersects(otherCourse, self.lookahead, true)
68+
if myDistanceToCollision then
69+
-- our course intersects with this vehicle's course (lastSpeedReal is in m/ms)
70+
-- for our own ETE, we always use the field speed and not the actual speed. This is to make sure
71+
-- we come to a full stop on a warning and remain stopped while the warning is active
72+
local myEte = myDistanceToCollision / (self.strategy:getFieldSpeed())
73+
local otherEte = CpMathUtil.divide(otherDistanceToCollision, (vehicle.lastSpeedReal * 1000))
74+
-- self:debug('Checking %s at %.1f m, %.1f, ETE %.1f %.1f', CpUtil.getName(vehicle), d, myDistanceToCollision, myEte, otherEte)
75+
if math.abs(myEte - otherEte) < self.eteDiffThreshold then
76+
if not self.warning:get() or (self.warning:get() and vehicle ~= self.warningVehicle) then
77+
-- no warning is active yet, or there is, but this is a different vehicle
78+
self:debug('collision warning: my course intersects with %s in %.1f m, my ETE %.1f, other ETE %.1f',
79+
CpUtil.getName(vehicle), myDistanceToCollision, myEte, otherEte)
8580
end
81+
self.warningVehicle = vehicle
82+
self.warning:set(true, self.clearWarningDelayMs)
83+
return
8684
end
8785
end
8886
end

scripts/ai/PurePursuitController.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ function PurePursuitController:getLookaheadDistance()
236236
return self.lookAheadDistance
237237
end
238238

239+
function PurePursuitController:getNormalLookaheadDistance()
240+
return self.normalLookAheadDistance
241+
end
242+
239243
function PurePursuitController:setCurrentLookaheadDistance(cte)
240244
local la = self.temporaryLookAheadDistance:get() or self.baseLookAheadDistance
241245
self.lookAheadDistance = math.min(la + math.abs(cte), la * 2)

0 commit comments

Comments
 (0)