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

Commit

Permalink
6.03.00037 Fix for very long implements and offset
Browse files Browse the repository at this point in the history
Do not reset tool offset when starting, only on attach (fixes #6781)

Use the back marker offset when constructing the finish row course to make
sure it is long enough even in case of insanely long implements (fixes #6652)
  • Loading branch information
pvaiko authored Feb 7, 2021
1 parent 84f79d2 commit b899a62
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 26 deletions.
2 changes: 1 addition & 1 deletion config/VehicleConfigurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ You can define the following custom settings:
<!--vehicles\gregoireBesson-->
<Vehicle name="SPSL9.xml"
toolOffsetX="2.1"
turnRadius = "10"
turnRadius = "7.5"
implementWheelAlwaysOnGround = "true"
workingWidth = "10.5"
/>
Expand Down
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="47">
<version>6.03.00036</version>
<version>6.03.00037</version>
<author><![CDATA[Courseplay.devTeam]]></author>
<title><!-- en=English de=German fr=French es=Spanish ru=Russian pl=Polish it=Italian br=Brazilian-Portuguese cs=Chinese(Simplified) ct=Chinese(Traditional) cz=Czech nl=Netherlands hu=Hungary jp=Japanese kr=Korean pt=Portuguese ro=Romanian tr=Turkish -->
<en>CoursePlay SIX</en>
Expand Down
7 changes: 4 additions & 3 deletions toolManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function courseplay:updateOnAttachOrDetach(vehicle)
end

courseplay:resetTools(vehicle)

-- reset tool offset to the preconfigured value if exists
vehicle.cp.settings.toolOffsetX:setToConfiguredValue()

end

--- Set up tool configuration after something is attached or detached
Expand All @@ -61,9 +65,6 @@ function courseplay:resetTools(vehicle)
courseplay.hud:setReloadPageOrder(vehicle, -1, true);

courseplay:calculateWorkWidth(vehicle, true);

-- reset tool offset to the preconfigured value if exists
vehicle.cp.settings.toolOffsetX:setToConfiguredValue()
end;

function courseplay:isAttachedMixer(workTool)
Expand Down
19 changes: 11 additions & 8 deletions turn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1812,8 +1812,8 @@ TurnContext = CpObject()
--- node so when the vehicle's root node reaches the vehicleAtTurnEndNode, the front of the work area will exactly be on the
--- turn end node. (The vehicle must be steered to the vehicleAtTurnEndNode instead of the turn end node so the implements
--- reach exactly the row end)
---@param backMarkerDistance number distance of the rearmost work area from the vehicle's root node. Will only be used
--- to pass in to turn generator code and should be reviewed if it is needed at all.
---@param backMarkerDistance number distance of the rearmost work area from the vehicle's root node. Will be used
--- to pass in to turn generator code and to calculate the minimum length of the row finishing course.
---@param turnEndSideOffset number offset of the turn end in meters to left (>0) or right (<0) to end the turn left or
--- right of the turn end node. Used when there's an offset to consider, for example because the implement is not
--- in the middle, like plows.
Expand Down Expand Up @@ -1863,7 +1863,8 @@ function TurnContext:init(course, turnStartIx, aiDriverData, workWidth,

self.dx, _, self.dz = localToLocal(self.turnEndWpNode.node, self.workEndNode, 0, 0, 0)
self.leftTurn = self.dx > 0
self:debug('start ix = %d', turnStartIx)
self:debug('start ix = %d, back marker = %.1f, front marker = %.1f',
turnStartIx, self.backMarkerDistance, self.frontMarkerDistance)
end

function TurnContext:debug(...)
Expand Down Expand Up @@ -2192,13 +2193,15 @@ end
---@return Course
function TurnContext:createFinishingRowCourse(vehicle)
local waypoints = {}
-- must be at least as long as the front marker distance so we are not reaching the end of the course before
-- the implement reaches the field edge (a negative frontMarkerDistance means the implement is behind the
-- vehicle, this isn't a problem for a positive frontMarkerDistance as the implement reaches the field edge
-- must be at least as long as the back marker distance so we are not reaching the end of the course before
-- the implement reaches the field edge (a negative backMarkerDistance means the implement is behind the
-- vehicle, this isn't a problem for a positive backMarkerDistance as the implement reaches the field edge
-- before the vehicle (except for very wide work widths of course, so make sure we have enough course to cross
-- the headland)
-- TODO: fix this properly, maybe we should check the end course during turns instead
for d = 0, math.max(self.workWidth * 1.5, -self.frontMarkerDistance * 6), 1 do
-- (back marker is the worst case, for when the raise implement is set to 'late'. If it is set to 'early',
-- the front marker distance would be here relevant but this is only for creating the course, where the vehicle will
-- stop finishing the row and start the turn depends only on the raise implement setting.
for d = 0, math.max(self.workWidth * 1.5, -self.backMarkerDistance * 1.5), 1 do
local x, _, z = localToWorld(self.workEndNode, 0, 0, d)
table.insert(waypoints, {x = x, z = z})
end
Expand Down
36 changes: 23 additions & 13 deletions vehicles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -774,11 +774,7 @@ end;

function courseplay:getToolTurnRadius(workTool)
local turnRadius = 0; -- Default value if none is set

if g_vehicleConfigurations:get(workTool, 'turnRadius') then
turnRadius = g_vehicleConfigurations:get(workTool, 'turnRadius')
courseplay:debug(('%s -> TurnRadius: using configured value of %.2fm'):format(nameNum(workTool), turnRadius), 6);
elseif courseplay:isWheeledWorkTool(workTool) then
if courseplay:isWheeledWorkTool(workTool) then
local radiusMultiplier = 1.05; -- Used to add a little bit to the radius, for safer turns.

local wheelBase = 0;
Expand Down Expand Up @@ -1559,23 +1555,37 @@ end

-- Get the turning radius of the vehicle and its implements (copied from AIDriveStrategyStraight.updateTurnData())
function AIDriverUtil.getTurningRadius(vehicle)
courseplay.debugVehicle(6, vehicle, 'Finding turn radius')
local radius = vehicle.maxTurningRadius * 1.1 -- needs ackermann steering
courseplay.debugVehicle(6, vehicle, 'Finding turn radius:')

local radius = vehicle.maxTurningRadius * 1.05 -- TODO: do we really need this buffer?
courseplay.debugVehicle(6, vehicle, ' maxTurningRadius by Giants is %.1f', vehicle.maxTurningRadius)
if vehicle:getAIMinTurningRadius() ~= nil then
courseplay.debugVehicle(6, vehicle, ' AIMinTurningRadius by Giants is %.1f', vehicle:getAIMinTurningRadius())
radius = math.max(radius, vehicle:getAIMinTurningRadius())
end
local maxToolRadius = 0

local attachedAIImplements = vehicle:getAttachedImplements()
local maxToolRadius = 0

for _, implement in pairs(attachedAIImplements) do
local turnRadius = AIVehicleUtil.getMaxToolRadius(implement)
if turnRadius == 0 then
turnRadius = courseplay:getToolTurnRadius(implement.object)
courseplay.debugVehicle(6, vehicle, '%s: no Giants turn radius, we calculated %.1f', implement.object:getName(), turnRadius)
local turnRadius = 0
if g_vehicleConfigurations:get(implement.object, 'turnRadius') then
turnRadius = g_vehicleConfigurations:get(implement.object, 'turnRadius')
courseplay.debugVehicle(6, vehicle, ' %s: using the configured turn radius %.1f',
implement.object:getName(), turnRadius)
else
turnRadius = AIVehicleUtil.getMaxToolRadius(implement)
if turnRadius > 0 then
courseplay.debugVehicle(6, vehicle, ' %s: using the Giants turn radius %.1f',
implement.object:getName(), turnRadius)
else
turnRadius = courseplay:getToolTurnRadius(implement.object)
courseplay.debugVehicle(6, vehicle, ' %s: no Giants turn radius, we calculated %.1f',
implement.object:getName(), turnRadius)
end
end
maxToolRadius = math.max(maxToolRadius, turnRadius)
courseplay.debugVehicle(6, vehicle, '%s: max tool radius %.1f', implement.object:getName(), maxToolRadius)
courseplay.debugVehicle(6, vehicle, ' %s: max tool radius now is %.1f', implement.object:getName(), maxToolRadius)
end
radius = math.max(radius, maxToolRadius)
courseplay.debugVehicle(6, vehicle, 'getTurningRadius: %.1f m', radius)
Expand Down

0 comments on commit b899a62

Please sign in to comment.