@@ -33,7 +33,7 @@ def __init__(self, x, y, cost, pind):
33
33
self .x = x # index of grid
34
34
self .y = y # index of grid
35
35
self .cost = cost
36
- self .pind = pind
36
+ self .pind = pind # index of previous Node
37
37
38
38
def __str__ (self ):
39
39
return str (self .x ) + "," + str (self .y ) + "," + str (self .cost ) + "," + str (self .pind )
@@ -88,10 +88,10 @@ def planning(self, sx, sy, gx, gy):
88
88
closedset [c_id ] = current
89
89
90
90
# expand search grid based on motion model
91
- for i , _ in enumerate ( self .motion ) :
92
- node = self .Node (current .x + self . motion [ i ][ 0 ] ,
93
- current .y + self . motion [ i ][ 1 ] ,
94
- current .cost + self . motion [ i ][ 2 ] , c_id )
91
+ for move_x , move_y , move_cost in self .motion :
92
+ node = self .Node (current .x + move_x ,
93
+ current .y + move_y ,
94
+ current .cost + move_cost , c_id )
95
95
n_id = self .calc_index (node )
96
96
97
97
if n_id in closedset :
@@ -124,11 +124,6 @@ def calc_final_path(self, ngoal, closedset):
124
124
125
125
return rx , ry
126
126
127
- def calc_heuristic (self , n1 , n2 ):
128
- w = 1.0 # weight of heuristic
129
- d = w * math .hypot (n1 .x - n2 .x , n1 .y - n2 .y )
130
- return d
131
-
132
127
def calc_position (self , index , minp ):
133
128
pos = index * self .reso + minp
134
129
return pos
@@ -242,6 +237,9 @@ def main():
242
237
dijkstra = Dijkstra (ox , oy , grid_size , robot_radius )
243
238
rx , ry = dijkstra .planning (sx , sy , gx , gy )
244
239
240
+ print (rx )
241
+ print (ry )
242
+
245
243
if show_animation : # pragma: no cover
246
244
plt .plot (rx , ry , "-r" )
247
245
plt .show ()
0 commit comments