Skip to content

Commit 874ebff

Browse files
authored
fix: set rrt_star to find the shortest path (AtsushiSakai#834)
* fix: set rrt_star to find the shortest path * fix: code style white space
1 parent dd6d046 commit 874ebff

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

PathPlanning/RRTStar/rrt_star.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,13 @@ def search_best_goal_node(self):
163163
if not safe_goal_inds:
164164
return None
165165

166-
min_cost = min([self.node_list[i].cost for i in safe_goal_inds])
167-
for i in safe_goal_inds:
168-
if self.node_list[i].cost == min_cost:
166+
safe_goal_costs = [self.node_list[i].cost +
167+
self.calc_dist_to_goal(self.node_list[i].x, self.node_list[i].y)
168+
for i in safe_goal_inds]
169+
170+
min_cost = min(safe_goal_costs)
171+
for i, cost in zip(safe_goal_inds, safe_goal_costs):
172+
if cost == min_cost:
169173
return i
170174

171175
return None

0 commit comments

Comments
 (0)