Skip to content

Commit

Permalink
6.01.00211 Proper fix for Courseplay#3748, driveInDirection enabled a…
Browse files Browse the repository at this point in the history
…gain

The last forward section of the tractor headland turn started back
at the implement, behind the tractor, so we used a dz < 0 to reach
the turn end. This for whatever reason worked with driveToPoint and
the tractor still drove forward, but driveInDirection (correctly) turned
back.

Do not a add an entire section now, just one waypoint well in front of
the tractor at the end of the turn to make sure stage 3/4 finishes and the
point is in front of the tractor.
  • Loading branch information
pvaiko committed May 8, 2019
1 parent a1f58fe commit 7cde880
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
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="40">
<version>6.01.00210</version>
<version>6.01.00211</version>
<author><![CDATA[Courseplay.devTeam]]></author>
<title>
<br>CoursePlay SIX</br>
Expand Down
33 changes: 14 additions & 19 deletions turn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ function courseplay:turn(vehicle, dt, turnContext)

local dist = courseplay:distance(curTurnTarget.posX, curTurnTarget.posZ, vehicleX, vehicleZ);

-- Set reverseing settings.
-- Set reversing settings.
if curTurnTarget.turnReverse then
refSpeed = vehicle.cp.speeds.reverse;
if reversingWorkTool and reversingWorkTool.cp.realTurningNode then
Expand Down Expand Up @@ -788,26 +788,21 @@ function courseplay:turn(vehicle, dt, turnContext)
directionForce = -vehicle.cp.mrAccelrator -- The progressive breaking function returns a postive number which accelerates the tractor
end
end
-- hold while straw swatch is active (not during headland turn maneuvers though)

-- hold while straw swath is active (not during headland turn maneuvers though)
local holdInTurn = not vehicle.cp.headlandTurn and vehicle.cp.driver and vehicle.cp.driver:holdInTurnManeuver(vehicle.cp.turnStage == 0)
allowedToDrive = not holdInTurn and allowedToDrive

--courseplay.debugVehicle(14, vehicle, 'turn speed = %.1f, allowedToDrive %s', refSpeed, allowedToDrive)
--vehicle,dt,steeringAngleLimit,acceleration,slowAcceleration,slowAngleLimit,allowedToDrive,moveForwards,lx,lz,maxSpeed,slowDownFactor,angle
if curTurnTarget and ((curTurnTarget.turnReverse and reversingWorkTool ~= nil) or (courseplay:onAlignmentCourse( vehicle ) and vehicle.cp.curTurnIndex < 2 )) then
if math.abs(vehicle.lastSpeedReal) < 0.0001 and not g_currentMission.missionInfo.stopAndGoBraking then
if not moveForwards then
vehicle.nextMovingDirection = -1
else
vehicle.nextMovingDirection = 1
end

if math.abs(vehicle.lastSpeedReal) < 0.0001 and not g_currentMission.missionInfo.stopAndGoBraking then
if not moveForwards then
vehicle.nextMovingDirection = -1
else
vehicle.nextMovingDirection = 1
end
end

AIVehicleUtil.driveInDirection(vehicle, dt, vehicle.cp.steeringAngle, directionForce, 0.5, 20, allowedToDrive, moveForwards, lx, lz, refSpeed, 1);

AIVehicleUtil.driveInDirection(vehicle, dt, vehicle.cp.steeringAngle, directionForce, 0.5, 20, allowedToDrive, moveForwards, lx, lz, refSpeed, 1);
else
dtpZ = dtpZ * 0.85;
AIVehicleUtil.driveToPoint(vehicle, dt, directionForce, allowedToDrive, moveForwards, dtpX, dtpZ, refSpeed);
end;
courseplay:setTrafficCollision(vehicle, lx, lz, true);
end;

Expand Down Expand Up @@ -1774,9 +1769,9 @@ function courseplay.generateTurnTypeHeadlandCornerReverseStraightTractor(vehicle
vehicle.cp.turnTargets[#vehicle.cp.turnTargets].lowerImplement = true

--- Finish the turn
fromPoint.x, fromPoint.z = toPoint.x, toPoint.z
toPoint = vehicle.cp.turnCorner:getPointAtDistanceFromArcEnd(3)
courseplay:generateTurnStraightPoints(vehicle, stopDir, toPoint, false, true);
-- add just one target well forward, making sure it is in front of the tractor
courseplay:addTurnTarget(vehicle, toPoint.x, toPoint.z, true, false)
end

function courseplay:getTurnCircleTangentIntersectionPoints(cp, np, radius, leftTurn)
Expand Down

0 comments on commit 7cde880

Please sign in to comment.