Skip to content

Commit

Permalink
fix: reversing with offset tools
Browse files Browse the repository at this point in the history
For reversing, use the steering node only if
AIVehicleUtil.getAIToolReverserDirectionNode()
does not exist.
  • Loading branch information
pvaiko committed Sep 12, 2023
1 parent 0366a34 commit a0b6571
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
5 changes: 0 additions & 5 deletions config/VehicleConfigurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ You can define the following custom settings:
<!--\vehicles\ropa-->
<Vehicle name="keiler2.xml"
toolOffsetX = "-2.0"
noReverse = "true"
/>
<!--\vehicles\ropa-->
<Vehicle name="nawaRoMaus.xml"
Expand Down Expand Up @@ -228,12 +227,10 @@ You can define the following custom settings:
/>
<!--\vehicles\lemken-->
<Vehicle name="titan11.xml"
noReverse = "true"
turnRadius = "7.5"
implementWheelAlwaysOnGround = "true"
/>
<Vehicle name="titan18.xml"
noReverse="true"
turnRadius = "7.5"
implementWheelAlwaysOnGround = "true"
raiseLate = "true"
Expand All @@ -252,7 +249,6 @@ You can define the following custom settings:
noReverse = "false"
turnRadius = "9"
/>
<!--vehicles\seedHawk-->
<Vehicle name="980AirCart.xml"
noReverse = "true"
/>
Expand Down Expand Up @@ -406,7 +402,6 @@ You can define the following custom settings:
turnRadius = "7.5"
implementWheelAlwaysOnGround = "true"
workingWidth = "10.5"
noReverse = "true"
/>
<!--Mod: KOECKERLING Vector 460-->
<Vehicle name="vector460.xml"
Expand Down
17 changes: 10 additions & 7 deletions scripts/ai/AIReverseDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,22 @@ function AIReverseDriver:getDriveData()
return nil
end

local trailerNode = self.reversingImplement.steeringAxleNode
local xTipper, yTipper, zTipper = getWorldTranslation(trailerNode);
-- if there's a reverser node on the tool, use that, otherwise the steering node
-- the reverser direction node, if exists, works better for tools with offset or for
-- rotating plows where it remains oriented and placed correctly
local trailerNode = AIVehicleUtil.getAIToolReverserDirectionNode(self.vehicle) or self.reversingImplement.steeringAxleNode
local xTrailer, yTrailer, zTrailer = getWorldTranslation(trailerNode);

local trailerFrontNode = self.reversingImplement.reversingProperties.frontNode
local xFrontNode,yFrontNode,zFrontNode = getWorldTranslation(trailerFrontNode)

local tx, ty, tz = self.ppc:getGoalPointPosition()

local lxTipper, lzTipper = AIVehicleUtil.getDriveDirection(trailerNode, tx, ty, tz)
local lxTrailer, lzTrailer = AIVehicleUtil.getDriveDirection(trailerNode, tx, ty, tz)

self:showDirection(trailerNode, lxTipper, lzTipper, 1, 0, 0)
self:showDirection(trailerNode, lxTrailer, lzTrailer, 1, 0, 0)

local lxFrontNode, lzFrontNode = AIVehicleUtil.getDriveDirection(trailerFrontNode, xTipper, yTipper, zTipper)
local lxFrontNode, lzFrontNode = AIVehicleUtil.getDriveDirection(trailerFrontNode, xTrailer, yTrailer, zTrailer)

local lxTractor, lzTractor = 0, 0

Expand Down Expand Up @@ -95,7 +98,7 @@ function AIReverseDriver:getDriveData()
local trailerToWaypointAngle = self:getLocalYRotationToPoint(trailerNode, tx, ty, tz, -1) * rotDelta
trailerToWaypointAngle = MathUtil.clamp(trailerToWaypointAngle, -math.rad(90), math.rad(90))

local dollyToTrailerAngle = self:getLocalYRotationToPoint(trailerFrontNode, xTipper, yTipper, zTipper, -1)
local dollyToTrailerAngle = self:getLocalYRotationToPoint(trailerFrontNode, xTrailer, yTrailer, zTrailer, -1)

local tractorToDollyAngle = self:getLocalYRotationToPoint(tractorNode, xFrontNode, yFrontNode, zFrontNode, -1)

Expand Down Expand Up @@ -192,7 +195,7 @@ end
function AIReverseDriver:calculateErrors(tractorNode, trailerNode)

-- PPC already has the cross track error (lateral error)
local crossTrackError = self.ppc:getCrossTrackError()
local crossTrackError = self.ppc:getCrossTrackError() --+ self.settings.toolOffsetX:getValue()

-- Calculate the orientation error, the angle between the trailers current direction and
-- the path direction
Expand Down
10 changes: 5 additions & 5 deletions scripts/ai/AIUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ end
function AIUtil.getReverserNode(vehicle, reversingImplement, suppressLog)
local reverserNode, debugText
-- if there's a reverser node on the tool, use that
reversingImplement = reversingImplement and reversingImplement or AIUtil.getFirstReversingImplementWithWheels(vehicle, suppressLog)
if reversingImplement and reversingImplement.steeringAxleNode then
reverserNode, debugText = reversingImplement.steeringAxleNode, 'implement steering axle node'
end
reverserNode, debugText = AIVehicleUtil.getAIToolReverserDirectionNode(vehicle), 'AIToolReverserDirectionNode'
if not reverserNode then
reverserNode, debugText = AIVehicleUtil.getAIToolReverserDirectionNode(vehicle), 'AIToolReverserDirectionNode'
reversingImplement = reversingImplement and reversingImplement or AIUtil.getFirstReversingImplementWithWheels(vehicle, suppressLog)
if reversingImplement and reversingImplement.steeringAxleNode then
reverserNode, debugText = reversingImplement.steeringAxleNode, 'implement steering axle node'
end
end
if not reverserNode and vehicle.getAIReverserNode then
reverserNode, debugText = vehicle:getAIReverserNode(), 'AIReverserNode'
Expand Down

0 comments on commit a0b6571

Please sign in to comment.