14
14
import scipy .spatial
15
15
import matplotlib .pyplot as plt
16
16
import reeds_shepp_path_planning as rs
17
+ import heapq
17
18
18
19
EXTEND_AREA = 5.0 # [m]
20
+ H_COST = 1.0
19
21
20
22
show_animation = True
21
23
22
24
23
25
class Node :
24
- """
25
- Node
26
- """
27
26
28
27
def __init__ (self , xind , yind , yawind , direction , x , y , yaw , directions , steer , cost , pind ):
29
28
# store kd-tree
@@ -117,7 +116,7 @@ def hybrid_a_star_planning(start, goal, ox, oy, xyreso, yawreso):
117
116
start [2 ], goal [2 ] = rs .pi_2_pi (start [2 ]), rs .pi_2_pi (goal [2 ])
118
117
tox , toy = ox [:], oy [:]
119
118
120
- obkdtree = KDTree (np .vstack ((tox , toy )).T )
119
+ # obkdtree = KDTree(np.vstack((tox, toy)).T)
121
120
122
121
c = Config (tox , toy , xyreso , yawreso )
123
122
@@ -126,11 +125,35 @@ def hybrid_a_star_planning(start, goal, ox, oy, xyreso, yawreso):
126
125
ngoal = Node (int (goal [0 ] / xyreso ), int (goal [1 ] / xyreso ), int (goal [2 ] / yawreso ),
127
126
True , [goal [0 ]], [goal [1 ]], [goal [2 ]], [True ], 0.0 , 0.0 , - 1 )
128
127
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
+
129
135
rx , ry , ryaw = [], [], []
130
136
131
137
return rx , ry , ryaw
132
138
133
139
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
+
134
157
def main ():
135
158
print ("Start rrt start planning" )
136
159
# ====Search Path with RRT====
0 commit comments