Skip to content

Commit

Permalink
Merge pull request #3484 from Courseplay/turn-fix
Browse files Browse the repository at this point in the history
Turn fixes
  • Loading branch information
Tensuko authored Oct 2, 2024
2 parents a390bc7 + d50cab4 commit eb09d0c
Show file tree
Hide file tree
Showing 5 changed files with 468 additions and 441 deletions.
2 changes: 1 addition & 1 deletion config/VehicleConfigurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ You can define the following custom settings:
<!--Implements-->
<!--Mod: Gregoire Besson SPSL9 -->
<Vehicle name="spsl9.xml"
turnRadius = "7.5"
turnRadius = "9.0"
implementWheelAlwaysOnGround = "true"
workingWidth = "10.5"
raiseLate = "true"
Expand Down
2 changes: 1 addition & 1 deletion scripts/Course.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ function Course:enrichWaypointData(startIx)
self.waypoints[i].curvature = i == 1 and 0 or 1 / self:calculateSignedRadius(i)
if (self:isReverseAt(i) and not self:switchingToForwardAt(i)) or self:switchingToReverseAt(i) then
-- X offset must be reversed at waypoints where we are driving in reverse
self.waypoints[i]:setReverseOffset()
self.waypoints[i]:setReverseOffset(true)
end
end
-- make the last waypoint point to the same direction as the previous so we don't
Expand Down
6 changes: 3 additions & 3 deletions scripts/Waypoint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function Waypoint:getOffsetPosition(offsetX, offsetZ, dx, dz)
-- check for NaN
if deltaX and deltaZ and deltaX == deltaX and deltaZ == deltaZ then
-- X offset should be inverted if we drive reverse here (left is always left regardless of the driving direction)
local reverse = self.rev and -1 or 1
local reverse = self.reverseOffset and -1 or 1
x = x - deltaZ * reverse * offsetX + deltaX * offsetZ
z = z + deltaX * reverse * offsetX + deltaZ * offsetZ
end
Expand Down Expand Up @@ -203,8 +203,8 @@ function Waypoint:setPosition(x, z, y)
end
end

function Waypoint:setReverseOffset()
self.reverseOffset = true
function Waypoint:setReverseOffset(reverseOffset)
self.reverseOffset = reverseOffset
end

function Waypoint:translate(dx, dz)
Expand Down
10 changes: 9 additions & 1 deletion scripts/ai/turns/AITurn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ end

--- Give back control the the drive strategy
function AITurn:resumeFieldworkAfterTurn(ix)
-- just in case, raise this event so plows are rotated to the working position. Should really never end up
-- here though, as the course should be long enough for the normal turn end processing to be triggered.
self.driveStrategy:raiseControllerEvent(AIDriveStrategyCourse.onTurnEndProgressEvent,
self.turnContext.workStartNode, self.ppc:isReversing(), true, self.turnContext:isLeftTurn())

if self.proximityController then
self.proximityController:unregisterBlockingObjectListener()
end
Expand Down Expand Up @@ -638,10 +643,13 @@ function CourseTurn:onWaypointChange(ix)
if self.turnCourse 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
self.tightTurnOffset = AIUtil.calculateTightTurnOffset(self.vehicle, self.turningRadius, self.turnCourse,
self.tightTurnOffset, true)
self.turnCourse:setOffset(self.tightTurnOffset, 0)
else
-- reset offset to 0 if tight turn offset is not on
self.tightTurnOffset = 0
self.turnCourse:setOffset(0, 0)
end
end
end
Expand Down
Loading

0 comments on commit eb09d0c

Please sign in to comment.