Skip to content

Commit 26fb451

Browse files
committed
fix astar logic
1 parent a45215e commit 26fb451

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

PathPlanning/AStar/a_star.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,10 @@ def a_star_planning(sx, sy, gx, gy, ox, oy, reso, rr):
9999

100100
if n_id not in openset:
101101
openset[n_id] = node # Discover a new node
102-
103-
tcost = current.cost + calc_heuristic(current, node)
104-
105-
if tcost >= node.cost:
106-
continue # this is not a better path
107-
108-
node.cost = tcost
109-
openset[n_id] = node # This path is the best unitl now. record it!
102+
else:
103+
if openset[n_id].cost >= node.cost:
104+
# This path is the best until now. record it!
105+
openset[n_id] = node
110106

111107
rx, ry = calc_fianl_path(ngoal, closedset, reso)
112108

0 commit comments

Comments
 (0)