Skip to content

Commit 0cb7c47

Browse files
authored
Merge pull request #1043 from Courseplay/1025-strange-issue-with-some-mulcherscultivators
1025 strange issue with some mulchers and cultivators
2 parents 4ae5313 + a3d4058 commit 0cb7c47

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

scripts/pathfinder/Dubins.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ function DubinsSolution:getLength(turnRadius)
4646
end
4747

4848
function DubinsSolution:getWaypoints(start, turnRadius)
49-
return dubins_path_sample_many(self.pathDescriptor, 1)
49+
-- waypoints are 1 m apart, but make sure there are at least 12 waypoints per half circle
50+
-- even with very small radii
51+
return dubins_path_sample_many(self.pathDescriptor, math.min(1, turnRadius * math.pi / 12))
5052
end
5153

5254
local twoPi = 2 * math.pi

scripts/pathfinder/ReedsShepp.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ function ReedsShepp.ActionSet:addAction(steer, gear, length)
138138
end
139139

140140
function ReedsShepp.ActionSet:calculateCost(unit, reverseCostMultiplier, gearSwitchCost)
141-
if reverseCostMultiplier == 1 and gearSwitchCost == 0 then return self.Length * unit end
142-
if self.Length == math.huge or #self.ctions == 0 then return math.huge end
141+
if reverseCostMultiplier == 1 and gearSwitchCost == 0 then return self.length * unit end
142+
if self.length == math.huge or #self.actions == 0 then return math.huge end
143143
local cost = 0
144144
local prevGear = self.actions[1].gear
145145
for _, a in ipairs(self.actions) do
146-
local actionCost = a.Length * unit
146+
local actionCost = a.length * unit
147147
if a.gear == Gear.Backward then
148148
actionCost = actionCost * reverseCostMultiplier
149149
end
@@ -174,7 +174,9 @@ function ReedsShepp.ActionSet:getWaypoints(start, turnRadius)
174174
local waypoints = {}
175175
table.insert(waypoints, prev)
176176
for _, action in ipairs(self.actions) do
177-
local n = math.ceil(action.length * turnRadius)
177+
-- waypoints are 1 m apart, but make sure there are at least 12 waypoints per half circle
178+
-- even with very small radii
179+
local n = math.ceil(math.max(action.length * turnRadius, action.length / math.pi * 12))
178180
if action.steer ~= Steer.Straight then
179181
local pieceAngle = action.length / n
180182

0 commit comments

Comments
 (0)