-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimplifier.py
More file actions
34 lines (24 loc) · 971 Bytes
/
simplifier.py
File metadata and controls
34 lines (24 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from vision import Vision
from collision import Collision
class Simplifier:
def __init__(self, vision: Vision):
self.vision = vision
self.collision = Collision(self.vision)
def simplify(self, waypoint_list: list) -> list:
new_waypoint_list = []
new_waypoint_list.append(waypoint_list[0])
i = 0
while i < len(waypoint_list) - 1:
line_x1, line_y1 = waypoint_list[i]
j = len(waypoint_list) - 1
while j != i:
if self.collision.is_collided_check_all(line_x1, line_y1,
waypoint_list[j][0], waypoint_list[j][1]) == False:
new_waypoint_list.append(waypoint_list[j])
i = j - 1
break
j -= 1
if (j == i):
new_waypoint_list.append(waypoint_list[i + 1])
i += 1
return new_waypoint_list