@@ -138,12 +138,12 @@ function ReedsShepp.ActionSet:addAction(steer, gear, length)
138138end
139139
140140function 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