Skip to content

Commit d46fecc

Browse files
committed
keep coding
1 parent cd5eb79 commit d46fecc

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

PathPlanning/HybridAStar/hybrid_a_star.py

+27-4
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
import scipy.spatial
1515
import matplotlib.pyplot as plt
1616
import reeds_shepp_path_planning as rs
17+
import heapq
1718

1819
EXTEND_AREA = 5.0 # [m]
20+
H_COST = 1.0
1921

2022
show_animation = True
2123

2224

2325
class Node:
24-
"""
25-
Node
26-
"""
2726

2827
def __init__(self, xind, yind, yawind, direction, x, y, yaw, directions, steer, cost, pind):
2928
# store kd-tree
@@ -117,7 +116,7 @@ def hybrid_a_star_planning(start, goal, ox, oy, xyreso, yawreso):
117116
start[2], goal[2] = rs.pi_2_pi(start[2]), rs.pi_2_pi(goal[2])
118117
tox, toy = ox[:], oy[:]
119118

120-
obkdtree = KDTree(np.vstack((tox, toy)).T)
119+
# obkdtree = KDTree(np.vstack((tox, toy)).T)
121120

122121
c = Config(tox, toy, xyreso, yawreso)
123122

@@ -126,11 +125,35 @@ def hybrid_a_star_planning(start, goal, ox, oy, xyreso, yawreso):
126125
ngoal = Node(int(goal[0] / xyreso), int(goal[1] / xyreso), int(goal[2] / yawreso),
127126
True, [goal[0]], [goal[1]], [goal[2]], [True], 0.0, 0.0, -1)
128127

128+
openList, closedList = {}, {}
129+
h = []
130+
# goalqueue = queue.PriorityQueue()
131+
pq = []
132+
openList[calc_index(nstart, c)] = nstart
133+
heapq.heappush(pq, (calc_index(nstart, c), calc_cost(nstart, h, ngoal, c)))
134+
129135
rx, ry, ryaw = [], [], []
130136

131137
return rx, ry, ryaw
132138

133139

140+
def calc_cost(n, h, ngoal, c):
141+
142+
hcost = 1.0
143+
144+
return (n.cost + H_COST * hcost)
145+
146+
147+
def calc_index(node, c):
148+
ind = (node.yawind - c.minyaw) * c.xw * c.yw + \
149+
(node.yind - c.miny) * c.xw + (node.xind - c.minx)
150+
151+
if ind <= 0:
152+
print("Error(calc_index):", ind)
153+
154+
return ind
155+
156+
134157
def main():
135158
print("Start rrt start planning")
136159
# ====Search Path with RRT====

0 commit comments

Comments
 (0)