Skip to content

Commit 06438d4

Browse files
authored
Merge pull request AtsushiSakai#291 from sldai/issue_285
fix RRT rewire
2 parents 3d772e9 + cacb6db commit 06438d4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

PathPlanning/RRTStar/rrt_star.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(self, x, y):
3434
self.cost = 0.0
3535

3636
def __init__(self, start, goal, obstacle_list, rand_area,
37-
expand_dis=3.0,
37+
expand_dis=30.0,
3838
path_resolution=1.0,
3939
goal_sample_rate=20,
4040
max_iter=300,
@@ -141,6 +141,9 @@ def search_best_goal_node(self):
141141
def find_near_nodes(self, new_node):
142142
nnode = len(self.node_list) + 1
143143
r = self.connect_circle_dist * math.sqrt((math.log(nnode) / nnode))
144+
# if expand_dist exists, search vertices in a range no more than expand_dist
145+
if hasattr(self, 'expand_dis'):
146+
r = min(r, self.expand_dis)
144147
dist_list = [(node.x - new_node.x) ** 2 +
145148
(node.y - new_node.y) ** 2 for node in self.node_list]
146149
near_inds = [dist_list.index(i) for i in dist_list if i <= r ** 2]
@@ -158,8 +161,7 @@ def rewire(self, new_node, near_inds):
158161
improved_cost = near_node.cost > edge_node.cost
159162

160163
if no_collision and improved_cost:
161-
near_node = edge_node
162-
near_node.parent = new_node
164+
self.node_list[i] = edge_node
163165
self.propagate_cost_to_leaves(new_node)
164166

165167
def calc_new_cost(self, from_node, to_node):

0 commit comments

Comments
 (0)