Skip to content

Commit fa374c7

Browse files
committed
imporve covergage ratio
1 parent e156fe1 commit fa374c7

20 files changed

+34
-58
lines changed

PathPlanning/ClosedLoopRRTStar/closed_loop_rrt_star_car.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -138,26 +138,6 @@ def search_best_feasible_path(self, path_indexs):
138138

139139
return False, None, None, None, None, None, None, None
140140

141-
def calc_tracking_path(self, path):
142-
path = np.array(path[::-1])
143-
ds = 0.2
144-
for i in range(10):
145-
lx = path[-1, 0]
146-
ly = path[-1, 1]
147-
lyaw = path[-1, 2]
148-
move_yaw = math.atan2(path[-2, 1] - ly, path[-2, 0] - lx)
149-
if abs(lyaw - move_yaw) >= math.pi / 2.0:
150-
print("back")
151-
ds *= -1
152-
153-
lstate = np.array(
154-
[lx + ds * math.cos(lyaw), ly + ds * math.sin(lyaw), lyaw])
155-
# print(lstate)
156-
157-
path = np.vstack((path, lstate))
158-
159-
return path
160-
161141
def check_tracking_path_is_feasible(self, path):
162142
# print("check_tracking_path_is_feasible")
163143
cx = np.array(path[:, 0])
@@ -311,9 +291,9 @@ def find_near_nodes(self, newNode):
311291
nnode = len(self.nodeList)
312292
r = 50.0 * math.sqrt((math.log(nnode) / nnode))
313293
# r = self.expandDis * 5.0
314-
dlist = [(node.x - newNode.x) ** 2 +
315-
(node.y - newNode.y) ** 2 +
316-
(node.yaw - newNode.yaw) ** 2
294+
dlist = [(node.x - newNode.x) ** 2
295+
+ (node.y - newNode.y) ** 2
296+
+ (node.yaw - newNode.yaw) ** 2
317297
for node in self.nodeList]
318298
nearinds = [dlist.index(i) for i in dlist if i <= r ** 2]
319299
return nearinds
@@ -336,7 +316,7 @@ def rewire(self, newNode, nearinds):
336316
# print("rewire")
337317
self.nodeList[i] = tNode
338318

339-
def DrawGraph(self, rnd=None):
319+
def DrawGraph(self, rnd=None): # pragma: no cover
340320
"""
341321
Draw Graph
342322
"""
@@ -359,9 +339,9 @@ def DrawGraph(self, rnd=None):
359339
plt.pause(0.01)
360340

361341
def GetNearestListIndex(self, nodeList, rnd):
362-
dlist = [(node.x - rnd.x) ** 2 +
363-
(node.y - rnd.y) ** 2 +
364-
(node.yaw - rnd.yaw) ** 2 for node in nodeList]
342+
dlist = [(node.x - rnd.x) ** 2
343+
+ (node.y - rnd.y) ** 2
344+
+ (node.yaw - rnd.yaw) ** 2 for node in nodeList]
365345
minind = dlist.index(min(dlist))
366346

367347
return minind

PathPlanning/ClosedLoopRRTStar/pure_pursuit.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ def closed_loop_prediction(cx, cy, cyaw, speed_profile, goal):
131131
a.append(ai)
132132
d.append(di)
133133

134-
if target_ind % 1 == 0 and animation:
134+
if target_ind % 1 == 0 and animation: # pragma: no cover
135135
plt.cla()
136136
plt.plot(cx, cy, "-r", label="course")
137137
plt.plot(x, y, "ob", label="trajectory")
138138
plt.plot(cx[target_ind], cy[target_ind], "xg", label="target")
139139
plt.axis("equal")
140140
plt.grid(True)
141-
plt.title("speed:" + str(round(state.v, 2)) +
142-
"tind:" + str(target_ind))
141+
plt.title("speed:" + str(round(state.v, 2))
142+
+ "tind:" + str(target_ind))
143143
plt.pause(0.0001)
144144

145145
else:
@@ -196,7 +196,7 @@ def calc_speed_profile(cx, cy, cyaw, target_speed):
196196

197197
speed_profile, d = set_stop_point(target_speed, cx, cy, cyaw)
198198

199-
if animation:
199+
if animation: # pragma: no cover
200200
plt.plot(speed_profile, "xb")
201201

202202
return speed_profile
@@ -220,7 +220,7 @@ def extend_path(cx, cy, cyaw):
220220
return cx, cy, cyaw
221221

222222

223-
def main():
223+
def main(): # pragma: no cover
224224
# target course
225225
cx = np.arange(0, 50, 0.1)
226226
cy = [math.sin(ix / 5.0) * ix / 2.0 for ix in cx]
@@ -277,15 +277,15 @@ def main():
277277
plt.axis("equal")
278278
plt.grid(True)
279279

280-
subplots(1)
280+
plt.subplots(1)
281281
plt.plot(t, [iv * 3.6 for iv in v], "-r")
282282
plt.xlabel("Time[s]")
283283
plt.ylabel("Speed[km/h]")
284284
plt.grid(True)
285285
plt.show()
286286

287287

288-
def main2():
288+
def main2(): # pragma: no cover
289289
import pandas as pd
290290
data = pd.read_csv("rrt_course.csv")
291291
cx = np.array(data["x"])
@@ -321,7 +321,7 @@ def main2():
321321
plt.show()
322322

323323

324-
if __name__ == '__main__':
324+
if __name__ == '__main__': # pragma: no cover
325325
print("Pure pursuit path tracking simulation start")
326326
# main()
327327
main2()

PathPlanning/ClosedLoopRRTStar/unicycle_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def pi_2_pi(angle):
4242
return (angle + math.pi) % (2 * math.pi) - math.pi
4343

4444

45-
if __name__ == '__main__':
45+
if __name__ == '__main__': # pragma: no cover
4646
print("start unicycle simulation")
4747
import matplotlib.pyplot as plt
4848

PathPlanning/RRTStarReedsShepp/rrt_star_reeds_shepp.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ def gen_final_course(self, goalind):
186186
node = self.nodeList[goalind]
187187
for (ix, iy) in zip(reversed(node.path_x), reversed(node.path_y)):
188188
path.append([ix, iy])
189-
# path.append([node.x, node.y])
190189
goalind = node.parent
191190
path.append([self.start.x, self.start.y])
192191
return path
@@ -222,10 +221,7 @@ def rewire(self, newNode, nearinds):
222221
# print("rewire")
223222
self.nodeList[i] = tNode
224223

225-
def DrawGraph(self, rnd=None):
226-
"""
227-
Draw Graph
228-
"""
224+
def DrawGraph(self, rnd=None): # pragma: no cover
229225
plt.clf()
230226
if rnd is not None:
231227
plt.plot(rnd.x, rnd.y, "^k")
@@ -313,7 +309,7 @@ def main(maxIter=200):
313309
path = rrt.Planning(animation=show_animation)
314310

315311
# Draw final path
316-
if show_animation:
312+
if show_animation: # pragma: no cover
317313
rrt.DrawGraph()
318314
plt.plot([x for (x, y) in path], [y for (x, y) in path], '-r')
319315
plt.grid(True)

tests/test_a_star.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ def test1(self):
1515
m.main()
1616

1717

18-
if __name__ == '__main__':
18+
if __name__ == '__main__': # pragma: no cover
1919
test = Test()
2020
test.test1()

tests/test_batch_informed_rrt_star.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ def test1(self):
1717
m.main(maxIter=10)
1818

1919

20-
if __name__ == '__main__':
20+
if __name__ == '__main__': # pragma: no cover
2121
test = Test()
2222
test.test1()

tests/test_closed_loop_rrt_star_car.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ def test1(self):
2020
m.main(gx=1.0, gy=0.0, gyaw=0.0, maxIter=5)
2121

2222

23-
if __name__ == '__main__':
23+
if __name__ == '__main__': # pragma: no cover
2424
test = Test()
2525
test.test1()

tests/test_dynamic_window_approach.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ def test1(self):
1818
m.main(gx=1.0, gy=1.0)
1919

2020

21-
if __name__ == '__main__':
21+
if __name__ == '__main__': # pragma: no cover
2222
test = Test()
2323
test.test1()

tests/test_fast_slam1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ def test1(self):
1919
m.main()
2020

2121

22-
if __name__ == '__main__':
22+
if __name__ == '__main__': # pragma: no cover
2323
test = Test()
2424
test.test1()

tests/test_fast_slam2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ def test1(self):
1919
m.main()
2020

2121

22-
if __name__ == '__main__':
22+
if __name__ == '__main__': # pragma: no cover
2323
test = Test()
2424
test.test1()

0 commit comments

Comments
 (0)