Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
6.03.00039 Mode 3 combine approach fixes #6612
Browse files Browse the repository at this point in the history
Forgotten vehicle parameter in OverloaderAIDriver caused it swerving
for the waiting combine.
  • Loading branch information
pvaiko committed Feb 11, 2021
1 parent de4bc52 commit 3f64862
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
10 changes: 7 additions & 3 deletions AIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2052,8 +2052,11 @@ function AIDriver:checkProximitySensor(maxSpeed, allowedToDrive, moveForwards)
-- check for nil and NaN
if deg and deg == deg and self:isProximitySwerveEnabled(vehicle) and
(not sameDirection or not vehicle:getIsCourseplayDriving()) then
local dx = dAvg * math.sin(math.rad(deg))
local dx = dAvg * math.sin(math.rad(deg)) -- dx > 0 is left
-- which direction to swerve (have a little bias for right, sorry UK folks :)
local gx, _, _ = self.ppc:getGoalPointLocalPosition()
local bias = gx - 1.2
-- TODO: use bias here instead of -1.2
local dir = dx > -1.2 and 1 or -1
self:setInfoText('SLOWING_DOWN_FOR_TRAFFIC')
self.ppc:setTemporaryShortLookaheadDistance(1000)
Expand All @@ -2064,8 +2067,9 @@ function AIDriver:checkProximitySensor(maxSpeed, allowedToDrive, moveForwards)
self.course:changeTemporaryOffsetX(offsetChange, 1000)
-- always slow down when swerving
newSpeed = slowSpeed
debug(AIDriver.psStateSwerve, 'dAvg = %.1f (%d), speed = %.1f, swerve dx = %.1f, setPoint = %.1f, error = %.1f, offsetChange = %.1f',
dAvg, 100 * normalizedD, newSpeed, dx, setPoint, error, offsetChange)
debug(AIDriver.psStateSwerve,
'dAvg = %.1f (%d), speed = %.1f, swerve dx = %.1f, setPoint = %.1f, error = %.1f, offsetChange = %.1f, (%s)',
dAvg, 100 * normalizedD, newSpeed, dx, setPoint, error, offsetChange, nameNum(vehicle))
else
if self:isProximitySlowDownEnabled(vehicle) then
newSpeed = slowSpeed
Expand Down
25 changes: 15 additions & 10 deletions CombineUnloadAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1684,18 +1684,27 @@ function CombineUnloadAIDriver:changeToUnloadWhenFull()
end
return false
end
------------------------------------------------------------------------------------------------------------------------
-- Drive to stopped combine
------------------------------------------------------------------------------------------------------------------------
function CombineUnloadAIDriver:driveToCombine()

function CombineUnloadAIDriver:checkForCombineProximity()
-- do not swerve for our combine towards the end of the course,
-- otherwise we won't be able to align with it when coming from
-- the wrong angle
if self.course:getDistanceToLastWaypoint(self.course:getCurrentWaypointIx()) < 20 then
if not self.doNotSwerveForVehicle:get() then
self:debug('Disable swerve for %s', nameNum(self.combineToUnload))
end
self.doNotSwerveForVehicle:set(self.combineToUnload, 2000)
end

end

------------------------------------------------------------------------------------------------------------------------
-- Drive to stopped combine
------------------------------------------------------------------------------------------------------------------------
function CombineUnloadAIDriver:driveToCombine()

self:checkForCombineProximity()

courseplay:setInfoText(self.vehicle, "COURSEPLAY_DRIVE_TO_COMBINE");

self:setFieldSpeed()
Expand All @@ -1711,12 +1720,8 @@ end
-- Drive to moving combine
------------------------------------------------------------------------------------------------------------------------
function CombineUnloadAIDriver:driveToMovingCombine()
-- do not swerve for our combine towards the end of the course,
-- otherwise we won't be able to align with it when coming from
-- the wrong angle
if self.course:getDistanceToLastWaypoint(self.course:getCurrentWaypointIx()) < 20 then
self.doNotSwerveForVehicle:set(self.combineToUnload, 2000)
end

self:checkForCombineProximity()

courseplay:setInfoText(self.vehicle, "COURSEPLAY_DRIVE_TO_COMBINE");

Expand Down
4 changes: 3 additions & 1 deletion DevHelper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ function DevHelper:updateProximitySensors(vehicle)
if vehicle.cp.driver.forwardLookingProximitySensorPack then
local d, otherVehicle, object, deg, dAvg =
vehicle.cp.driver.forwardLookingProximitySensorPack:getClosestObjectDistanceAndRootVehicle()
end
--renderText(0.6, 0.4, 0.018, string.format('d=%.1f %s deg=%.1f dAvg=%.1f dx=%.1f (%s)',
-- d, nameNum(otherVehicle), deg, dAvg, dAvg * math.sin(math.rad(deg)), nameNum(vehicle)))
end
if vehicle.cp.driver.backwardLookingProximitySensorPack then
local d, otherVehicle, object, deg, dAvg =
vehicle.cp.driver.backwardLookingProximitySensorPack:getClosestObjectDistanceAndRootVehicle()
Expand Down
6 changes: 3 additions & 3 deletions OverloaderAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ function OverloaderAIDriver:isAugerPipeToolPositionsOkay(dt)
return true
end

-- make sure we stay close to the trailer while overloading
function OverloaderAIDriver:isProximitySwerveEnabled()
return CombineUnloadAIDriver.isProximitySwerveEnabled(self) and not self.nearOverloadPoint
function OverloaderAIDriver:isProximitySwerveEnabled(vehicle)
-- make sure we stay close to the trailer while overloading
return CombineUnloadAIDriver.isProximitySwerveEnabled(self, vehicle) and not self.nearOverloadPoint
end

function OverloaderAIDriver:isProximitySpeedControlEnabled()
Expand Down
2 changes: 1 addition & 1 deletion modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<modDesc descVersion="47">
<version>6.03.00038</version>
<version>6.03.00039</version>
<author><![CDATA[Courseplay.devTeam]]></author>
<title><!-- en=English de=German fr=French es=Spanish ru=Russian pl=Polish it=Italian br=Brazilian-Portuguese cs=Chinese(Simplified) ct=Chinese(Traditional) cz=Czech nl=Netherlands hu=Hungary jp=Japanese kr=Korean pt=Portuguese ro=Romanian tr=Turkish -->
<en>CoursePlay SIX</en>
Expand Down

0 comments on commit 3f64862

Please sign in to comment.