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

Commit

Permalink
034: Fixing Wide Turns not working on headlands.
Browse files Browse the repository at this point in the history
  • Loading branch information
Satissis committed Dec 13, 2016
1 parent e8cd4dd commit 8524d5e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
@@ -1,3 +1,7 @@
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf

# tab indentation
[*.{xml,lua}]
indent_style = tab
Expand Down
2 changes: 1 addition & 1 deletion modDesc.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<modDesc descVersion="34">
<version>5.00.00033</version>
<version>5.00.00034</version>
<author><![CDATA[Courseplay Dev Team]]></author>
<title>
<br>Courseplay</br>
Expand Down
2 changes: 2 additions & 0 deletions specialTools.lua
Expand Up @@ -224,6 +224,8 @@ function courseplay:setNameVariable(workTool)
-- New Holland SP.400F (Sprayer) [Giants]
elseif workTool.cp.xmlFileName == 'SP400F.xml' then
workTool.cp.isSP400F = true;
workTool.cp.directionNodeZOffset = 2.15;
workTool.cp.showDirectionNode = true; -- Only for debug mode 12
workTool.cp.widthWillCollideOnTurn = true;
-- Trucks [Giants]
Expand Down
20 changes: 10 additions & 10 deletions turn.lua
Expand Up @@ -202,10 +202,13 @@ function courseplay:turn(vehicle, dt)
end;

--- Calculate reverseOffset in case we need to reverse
--turnInfo.reverseOffset = turnInfo.zOffset + turnInfo.turnRadius + turnInfo.halfVehicleWidth - turnInfo.headlandHeight;
turnInfo.reverseOffset = turnInfo.turnRadius + turnInfo.halfVehicleWidth - turnInfo.headlandHeight;
if turnInfo.reverseOffset < 0 or not turnInfo.turnOnField then
turnInfo.reverseOffset = (turnInfo.turnOnField and 0 or --[[turnInfo.zOffset +]] -2);
if turnInfo.reverseOffset <= turnInfo.turnRadius + 0.01 or not turnInfo.turnOnField then
if turnInfo.turnOnField and turnInfo.reverseOffset > 0 then
turnInfo.reverseOffset = turnInfo.turnRadius;
else
turnInfo.reverseOffset = turnInfo.frontMarker > 0 and -turnInfo.zOffset - 5 or turnInfo.zOffset;
end;
end;

courseplay:debug(("%s:(Turn Data) frontMarker=%q, halfVehicleWidth=%q, directionNodeToTurnNodeLength=%q, wpChangeDistance=%q"):format(nameNum(vehicle), tostring(turnInfo.frontMarker), tostring(turnInfo.halfVehicleWidth), tostring(turnInfo.directionNodeToTurnNodeLength), tostring(turnInfo.wpChangeDistance)), 14);
Expand Down Expand Up @@ -545,7 +548,7 @@ function courseplay:generateTurnTypeWideTurn(vehicle, turnInfo)
local center1, center2, startDir, intersect1, intersect2, stopDir = {}, {}, {}, {}, {}, {};
-- Check if we can turn on the headlands
if (turnInfo.zOffset + turnInfo.turnRadius + turnInfo.halfVehicleWidth) < turnInfo.headlandHeight then
if (-turnInfo.zOffset + turnInfo.turnRadius + turnInfo.halfVehicleWidth) <= turnInfo.headlandHeight then
canTurnOnHeadland = true;
end;
Expand Down Expand Up @@ -603,7 +606,7 @@ function courseplay:generateTurnTypeWideTurn(vehicle, turnInfo)
--- Extra WP 3 - Turn End
else
posX, _, posZ = localToWorld(turnInfo.targetNode, 0, 0, turnInfo.directionNodeToTurnNodeLength + turnInfo.zOffset + 5);
posX, _, posZ = localToWorld(turnInfo.targetNode, 0, 0, -turnInfo.reverseOffset + turnInfo.directionNodeToTurnNodeLength + 5);
courseplay:addTurnTarget(vehicle, posX, posZ, false, true);
end;
end;
Expand All @@ -619,7 +622,7 @@ function courseplay:generateTurnTypeWideTurnWithAvoidance(vehicle, turnInfo)
local center, startDir, stopDir = {}, {}, {};
-- Check if we can turn on the headlands
if (turnInfo.zOffset + turnInfo.turnRadius + turnInfo.halfVehicleWidth) < turnInfo.headlandHeight then
if (-turnInfo.zOffset + turnInfo.turnRadius + turnInfo.halfVehicleWidth) < turnInfo.headlandHeight then
canTurnOnHeadland = true;
end;
Expand All @@ -636,9 +639,6 @@ function courseplay:generateTurnTypeWideTurnWithAvoidance(vehicle, turnInfo)
fromPoint.x, _, fromPoint.z = localToWorld(vehicle.cp.DirectionNode, 0, 0, -directionNodeToTurnNodeLength);
toPoint.x, _, toPoint.z = localToWorld(vehicle.cp.DirectionNode, 0, 0, turnInfo.zOffset - turnInfo.reverseOffset - directionNodeToTurnNodeLength - turnInfo.reverseWPChangeDistance);
courseplay:generateTurnStraitPoints(vehicle, fromPoint, toPoint, true, nil, turnInfo.reverseWPChangeDistance);-- Reverse back
--fromPoint.x, _, fromPoint.z = localToWorld(vehicle.cp.DirectionNode, 0, 0, (turnInfo.zOffset + turnInfo.directionNodeToTurnNodeLength + turnInfo.reverseWPChangeDistance) * -1);
--toPoint.x, _, toPoint.z = localToWorld(vehicle.cp.DirectionNode, 0, 0, (turnInfo.reverseOffset + turnInfo.directionNodeToTurnNodeLength + turnInfo.reverseWPChangeDistance) * -1);
--courseplay:generateTurnStraitPoints(vehicle, fromPoint, toPoint, true);
end;
----------------------------------------------------------
Expand Down Expand Up @@ -725,7 +725,7 @@ function courseplay:generateTurnTypeWideTurnWithAvoidance(vehicle, turnInfo)
--- Extra WP 3 - Turn End
else
posX, _, posZ = localToWorld(turnInfo.targetNode, 0, 0, turnInfo.directionNodeToTurnNodeLength + turnInfo.zOffset + 5);
posX, _, posZ = localToWorld(turnInfo.targetNode, 0, 0, -turnInfo.reverseOffset + turnInfo.directionNodeToTurnNodeLength + 5);
courseplay:addTurnTarget(vehicle, posX, posZ, false, true);
end;
end;
Expand Down

0 comments on commit 8524d5e

Please sign in to comment.