Skip to content

Commit bfc8744

Browse files
committed
🔨 Refcatored modification in pure_pursuit.py
Thanks to @AtsushiSakai remark AtsushiSakai#269 (comment)
1 parent f81140e commit bfc8744

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

PathTracking/pure_pursuit/pure_pursuit.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def search_target_index(self, state):
8080
# search nearest point index
8181
dx = [state.rear_x - icx for icx in self.cx]
8282
dy = [state.rear_y - icy for icy in self.cy]
83-
d = [idx ** 2 + idy ** 2 for (idx, idy) in zip(dx, dy)]
84-
ind = d.index(min(d))
83+
d = np.hypot(dx, dy)
84+
ind = np.argmin(d)
8585
self.old_nearest_point_index = ind
8686
else:
8787
ind = self.old_nearest_point_index
@@ -100,9 +100,7 @@ def search_target_index(self, state):
100100

101101
# search look ahead target point index
102102
while Lf > L and (ind + 1) < len(self.cx):
103-
dx = self.cx[ind] - state.rear_x
104-
dy = self.cy[ind] - state.rear_y
105-
L = math.hypot(dx, dy)
103+
L = state.calc_distance(self.cx[ind], self.cy[ind])
106104
ind += 1
107105

108106
return ind

0 commit comments

Comments
 (0)