AutoDrive Giants AI Helper Hand-over Fix Report
Hello AutoDrive team,
I wanted to share a tested fix for the Giants vanilla AI helper hand-over issue.
This is about the problem where AutoDrive reaches a field marker and starts the Giants AI helper, but the tractor drives back to the field where it worked previously instead of starting work on the current field.
This seems to be the same issue as AutoDrive GitHub issue #122:
"Enable AI at dest sends Giants AI to wrong field."
I know issue #122 was closed as wontfix / not planned, but we tested a small code change that appears to fix the Giants vanilla AI hand-over without breaking Courseplay hand-over.
Confirmed behaviour
- AutoDrive marker is placed inside the correct field.
- Manual Giants helper start works correctly on the new field.
- Courseplay hand-over works correctly.
- Problem only happens when AutoDrive starts the vanilla Giants helper.
- First Giants AI hand-over works.
- Second Giants AI hand-over with the same tractor on a different field reuses the old field and drives back there.
Root cause found
In:
scripts/Specialization.lua
inside the Giants AI hand-over logic, AutoDrive uses:
local fieldJob = vehicle:getLastJob()
That means if the tractor has already done a Giants AI job before, AutoDrive reuses the old AI job.
That old job still contains the previous field / old fieldwork target, so when AutoDrive starts the helper again, the tractor drives back to the old field.
Original logic
local fieldJob = vehicle:getLastJob()
if fieldJob == nil then
-- no job present - generate fieldwork job new
fieldJob = g_currentMission.aiJobTypeManager:createJob(AIJobType.FIELDWORK)
end
Working fix tested
Instead of reusing vehicle:getLastJob(), always create a fresh Giants fieldwork job when AutoDrive hands over to the vanilla Giants helper.
-- Always create a fresh Giants fieldwork job at the current AD destination.
-- Do not reuse vehicle:getLastJob(), because that can point to the old field.
local fieldJob = g_currentMission.aiJobTypeManager:createJob(AIJobType.FIELDWORK)
Also, this line needs to use true at the end:
fieldJob:applyCurrentState(vehicle, g_currentMission, vehicle:getOwnerFarmId(), true)
instead of:
fieldJob:applyCurrentState(vehicle, g_currentMission, vehicle:getOwnerFarmId(), false)
Full tested replacement section
if vehicle.getLastJob then
if vehicle.getIsOnField and vehicle:getIsOnField() then
AutoDrive.debugPrint(vehicle, AutoDrive.DC_EXTERNALINTERFACEINFO, "AutoDrive.passToExternalMod pass to Giants AI with fresh fieldwork job")
-- Always create a fresh Giants fieldwork job at the current AD destination.
-- Do not reuse vehicle:getLastJob(), because that can point to the old field.
local fieldJob = g_currentMission.aiJobTypeManager:createJob(AIJobType.FIELDWORK)
if fieldJob then
fieldJob:applyCurrentState(vehicle, g_currentMission, vehicle:getOwnerFarmId(), true)
fieldJob:setValues()
local success, errorMessage = fieldJob:validate(vehicle:getOwnerFarmId())
if success then
AutoDrive.debugPrint(vehicle, AutoDrive.DC_EXTERNALINTERFACEINFO, "AutoDrive.passToExternalMod fresh AI fieldwork job startJob")
g_currentMission.aiSystem:startJob(fieldJob, vehicle:getOwnerFarmId())
return
else
AutoDrive.debugPrint(vehicle, AutoDrive.DC_EXTERNALINTERFACEINFO, "AutoDrive.passToExternalMod fresh AI fieldwork job validation failed: %s", tostring(errorMessage))
end
end
end
else
return
end
Tested result
After this change:
- Courseplay hand-over still works.
- Giants vanilla AI helper hand-over works.
- Same tractor can be sent by AutoDrive to one field, start Giants AI, then later be sent to another field, and Giants AI starts on the new field instead of returning to the old one.
Summary
The issue appears to be caused by AutoDrive reusing the previous Giants AI job through:
For Giants vanilla AI hand-over, it works better to create a fresh:
from the tractor’s current position when AutoDrive reaches the field marker.
AutoDrive Giants AI Helper Hand-over Fix Report
Hello AutoDrive team,
I wanted to share a tested fix for the Giants vanilla AI helper hand-over issue.
This is about the problem where AutoDrive reaches a field marker and starts the Giants AI helper, but the tractor drives back to the field where it worked previously instead of starting work on the current field.
This seems to be the same issue as AutoDrive GitHub issue #122:
"Enable AI at dest sends Giants AI to wrong field."
I know issue #122 was closed as
wontfix/not planned, but we tested a small code change that appears to fix the Giants vanilla AI hand-over without breaking Courseplay hand-over.Confirmed behaviour
Root cause found
In:
inside the Giants AI hand-over logic, AutoDrive uses:
That means if the tractor has already done a Giants AI job before, AutoDrive reuses the old AI job.
That old job still contains the previous field / old fieldwork target, so when AutoDrive starts the helper again, the tractor drives back to the old field.
Original logic
Working fix tested
Instead of reusing
vehicle:getLastJob(), always create a fresh Giants fieldwork job when AutoDrive hands over to the vanilla Giants helper.Also, this line needs to use
trueat the end:instead of:
Full tested replacement section
Tested result
After this change:
Summary
The issue appears to be caused by AutoDrive reusing the previous Giants AI job through:
For Giants vanilla AI hand-over, it works better to create a fresh:
from the tractor’s current position when AutoDrive reaches the field marker.