fix: start AD igen hvis den aldrig kom i gang (CP-job ikke afsluttet) (v1.62.87)

This commit is contained in:
2026-10-08 11:08:03 +02:00
parent 83095ab1bd
commit be5da7f7c5
3 changed files with 14 additions and 1 deletions
+12
View File
@@ -25,6 +25,7 @@ ADHitch.ARRIVE_DISTANCE = 5 -- m fra markøren, AD standser traktoren tæ
ADHitch.DETACH_ARRIVE_DISTANCE = 8 -- afkobling: langt redskab (valse) står med roden >5 m inde i båsen
ADHitch.STILL_SPEED = 1 -- km/t
ADHitch.START_GRACE_MS = 3000 -- så længe må AD være om at komme i gang efter fetch/drop
ADHitch.START_RETRIES = 3 -- så mange nye startforsøg, hvis AD aldrig kom i gang (CP-job ikke afsluttet endnu)
ADHitch.ACT_TIMEOUT_MS = 8000 -- så længe forsøges kobling efter ankomst
ADHitch.DETACH_TIMEOUT_MS = 20000 -- afkobling: redskabet skal måske foldes ud først (plov: "unfold the tool")
ADHitch.TICK_MS = 250
@@ -195,6 +196,11 @@ function ADHitch.step(job, state, dt, succeeded)
end
elseif ADHitch.hasArrived(state) then
job.state = "acting"
elseif state.distance > arriveDistanceOf(state) and not job.seenActive and job.elapsed >= ADHitch.START_GRACE_MS
and (job.restarts or 0) < ADHitch.START_RETRIES then
-- AD kom aldrig i gang: AD afviser start, mens Courseplays job endnu ikke er afsluttet (in-game 8/10 F53:
-- hjemturen startede i samme sekund som CP sluttede -> 'stoppedAway (250 m)'). Prøv igen.
job.restarts, job.elapsed, job.restart = (job.restarts or 0) + 1, 0, true
elseif state.distance > arriveDistanceOf(state) and (job.seenActive or job.elapsed >= ADHitch.START_GRACE_MS) then
job.state, job.reason = "failed", string.format("stoppedAway (%.0f m fra markøren)", state.distance)
end
@@ -674,6 +680,12 @@ function ADHitch.tick(adEnv, dt)
local state = vehicleState(adEnv, vehicle, job.markerId)
state.arriveDistance = ADHitch.arriveDistanceFor(job.action, job.crept)
ADHitch.step(job, state, elapsed, succeeded)
if job.restart then
job.restart = nil
local okStart, errStart = pcall(ADFieldWork.startAd, adEnv, vehicle, adEnv.AutoDrive.MODE_DRIVETO, job.markerId)
Logging.info(ADHitch.LOG_PREFIX .. "'%s' kom ikke i gang mod '%s' — starter AD igen (forsøg %d)%s", vehicleName(vehicle),
tostring(job.markerName), job.restarts, okStart and "" or (": " .. tostring(errStart)))
end
if job.endTask then
job.endTask = nil
local taskModule = vehicle.ad ~= nil and vehicle.ad.taskModule or nil