Skip to content

Commit

Permalink
3 point turn fix for #141 and #162
Browse files Browse the repository at this point in the history
This fix does resolve the worst issues, but can
later be tweaked a little more to make it more
accurately observe field boundaries.
  • Loading branch information
pvaiko committed Dec 27, 2021
1 parent deb298e commit 5ae6422
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/ai/turns/AITurn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ end

function AITurn.canMakeKTurn(vehicle, turnContext, workWidth)
if turnContext:isHeadlandCorner() then
CpUtil.debugVehicle(AITurn.debugChannel, vehicle, 'Headland turn, let turn.lua drive for now.')
CpUtil.debugVehicle(AITurn.debugChannel, vehicle, 'Headland turn, not doing a 3 point turn.')
return false
end
local turningRadius = AIUtil.getTurningRadius(vehicle)
if turnContext.dx > 2 * turningRadius then
CpUtil.debugVehicle(AITurn.debugChannel, vehicle, 'Next row is too far (%.1f, turning radius is %.1f), no 3 point turn',
turnContext.dx, turningRadius)
return false
end
if not AIVehicleUtil.getAttachedImplementsAllowTurnBackward(vehicle) then
Expand All @@ -127,13 +133,13 @@ function AITurn.canMakeKTurn(vehicle, turnContext, workWidth)
CpUtil.debugVehicle(AITurn.debugChannel, vehicle, 'Have a towed implement, use generated course turn')
return false
end
local turningRadius = AIUtil.getTurningRadius(vehicle)
local settings = vehicle:getCpSettings()
if settings.turnOnField:getValue() and
not AITurn.canTurnOnField(turnContext, vehicle, workWidth, turningRadius) then
CpUtil.debugVehicle(AITurn.debugChannel, vehicle, 'Turn on field is on but there is not enough space, use generated course turn')
CpUtil.debugVehicle(AITurn.debugChannel, vehicle, 'Turn on field is on but there is not enough room to stay on field with a 3 point turn')
return false
end
CpUtil.debugVehicle(AITurn.debugChannel, vehicle, 'Can make a 3 point turn')
return true
end

Expand Down

0 comments on commit 5ae6422

Please sign in to comment.