From b899a62402902f19bd99be3e32bca7c27c4e8613 Mon Sep 17 00:00:00 2001 From: Peter Vaiko Date: Sun, 7 Feb 2021 17:44:31 -0600 Subject: [PATCH] 6.03.00037 Fix for very long implements and offset 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) --- config/VehicleConfigurations.xml | 2 +- modDesc.xml | 2 +- toolManager.lua | 7 ++++--- turn.lua | 19 ++++++++++------- vehicles.lua | 36 ++++++++++++++++++++------------ 5 files changed, 40 insertions(+), 26 deletions(-) diff --git a/config/VehicleConfigurations.xml b/config/VehicleConfigurations.xml index bcb0a485c..4065adb69 100644 --- a/config/VehicleConfigurations.xml +++ b/config/VehicleConfigurations.xml @@ -101,7 +101,7 @@ You can define the following custom settings: diff --git a/modDesc.xml b/modDesc.xml index ea17ed169..fa36f3d13 100644 --- a/modDesc.xml +++ b/modDesc.xml @@ -1,6 +1,6 @@ - 6.03.00036 + 6.03.00037 <!-- 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> diff --git a/toolManager.lua b/toolManager.lua index 7824ff511..cd92d29cf 100644 --- a/toolManager.lua +++ b/toolManager.lua @@ -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 @@ -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) diff --git a/turn.lua b/turn.lua index c63195ae2..f2ceb2d8d 100644 --- a/turn.lua +++ b/turn.lua @@ -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. @@ -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(...) @@ -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 diff --git a/vehicles.lua b/vehicles.lua index 214ab5a5a..64688f811 100644 --- a/vehicles.lua +++ b/vehicles.lua @@ -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; @@ -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)