Skip to content

Commit

Permalink
feat: config to disable tight turn offset
Browse files Browse the repository at this point in the history
Added vehicle config option to disable tight turn offset
in 180 turns.

#3173
  • Loading branch information
pvaiko committed Mar 28, 2024
1 parent 78734b5 commit e4243b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
10 changes: 9 additions & 1 deletion config/VehicleConfigurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ You can define the following custom settings:
Disables the pipe height adjustment for trailers of a few pipe implements/vehicles.
- ignorePipeMovingToolIndex: int
Ignores the given pipe moving tool by it's index.
Ignores the given pipe moving tool by its index.
This can be used to ignore a pipe moving part
and only use one part.
An example is the premium expansion Dewulf P3K Profi.
Expand All @@ -141,6 +141,13 @@ You can define the following custom settings:
Moving tool index for the pipe controller to control the pipe height.
This index is for the pipe part that is directly connected to the discharge node.
- disableTightTurnOffsetInTurns: boolean
"Tight turn offset" is extending the radius of a turn with a towed implement, in
order to keep the implement on the path, while the tractor is driving outside the
generated turn course. Setting this to true disables this, as some implements,
especially big plows turn on the spot and align better with the next row without
tight turn offset.
-->
<VehicleConfigurations>
<Configurations>
Expand Down Expand Up @@ -169,6 +176,7 @@ You can define the following custom settings:
<Configuration type="INT">basePipeMovingToolIndex</Configuration>
<Configuration type="INT">childPipeMovingToolIndex</Configuration>
<Configuration type="FLOAT">unloadOffsetX</Configuration>
<Configuration type="BOOL">disableTightTurnOffsetInTurns</Configuration>
</Configurations>
<!--[GIANTS]-->

Expand Down
7 changes: 4 additions & 3 deletions scripts/ai/AIUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,10 @@ end
---@param vehicle table
---@param object table
---@return boolean
function AIUtil.isObjectAttachedOnTheBack(vehicle,object)
local _, _, dz = localToLocal(object.rootNode, AIUtil.getDirectionNode(vehicle), 0, 0, 0)
if dz < 0 then
function AIUtil.isObjectAttachedOnTheBack(vehicle, object)
-- TODO: now in the implement's coordinate system, this is still not 100% reliable in turns
local _, _, dz = localToLocal(AIUtil.getDirectionNode(vehicle), object.rootNode, 0, 0, 0)
if dz > 0 then
return true
end
return false
Expand Down
8 changes: 5 additions & 3 deletions scripts/ai/turns/AITurn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,9 @@ end

function CourseTurn:onWaypointChange(ix)
AITurn.onWaypointChange(self, ix)
if self.turnCourse then
local tightTurnOffsetDisabled = not self.turnContext:isHeadlandCorner() and
g_vehicleConfigurations:getRecursively(self.vehicle, 'disableTightTurnOffsetInTurns')
if self.turnCourse and not tightTurnOffsetDisabled then
if self.forceTightTurnOffset or (self.enableTightTurnOffset and self.turnCourse:useTightTurnOffset(ix)) then
-- adjust the course a bit to the outside in a curve to keep a towed implement on the course
-- TODO_22
Expand Down Expand Up @@ -732,7 +734,7 @@ function CourseTurn:onPathfindingDone(path)
self.turnCourse:setUseTightTurnOffsetForLastWaypoints(15)
local endingTurnLength = self.turnContext:appendEndingTurnCourse(self.turnCourse, nil, true)
local x = AIUtil.getDirectionNodeToReverserNodeOffset(self.vehicle)
self:debug('Extending course at direction switch for reversing to %.1f m (or at least 1m)', -x )
self:debug('Extending course at direction switch for reversing to %.1f m (or at least 1m)', -x)
self.turnCourse:adjustForReversing(math.max(1, -x))
TurnManeuver.setLowerImplements(self.turnCourse, endingTurnLength, true)
else
Expand Down Expand Up @@ -987,7 +989,7 @@ function StartRowOnly:init(vehicle, driveStrategy, ppc, turnContext, startRowCou
local _, steeringLength = AIUtil.getSteeringParameters(self.vehicle)
self.enableTightTurnOffset = steeringLength > 0 and not AIUtil.hasArticulatedAxis(self.vehicle)

-- TODO: do we need tight turn offset here?
-- TODO: do we need tight turn offset here?
self.turnCourse:setUseTightTurnOffsetForLastWaypoints(15)
-- add a turn ending section into the row to make sure the implements are lowered correctly
local endingTurnLength = self.turnContext:appendEndingTurnCourse(self.turnCourse, 3, true)
Expand Down

0 comments on commit e4243b7

Please sign in to comment.