Skip to content

Commit ffab1f7

Browse files
authored
Merge pull request AtsushiSakai#148 from luym11/master
fixed steer() in RRTstar
2 parents a2830ba + 39a918a commit ffab1f7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

PathPlanning/RRTstar/rrt_star.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,16 @@ def steer(self, rnd, nind):
102102
# expand tree
103103
nearestNode = self.nodeList[nind]
104104
theta = math.atan2(rnd[1] - nearestNode.y, rnd[0] - nearestNode.x)
105-
newNode = copy.deepcopy(nearestNode)
106-
newNode.x += self.expandDis * math.cos(theta)
107-
newNode.y += self.expandDis * math.sin(theta)
108-
109-
newNode.cost += self.expandDis
110-
newNode.parent = nind
105+
newNode = Node(rnd[0], rnd[1])
106+
currentDistance = math.sqrt( (rnd[1] - nearestNode.y) ** 2 + (rnd[0] - nearestNode.x) ** 2)
107+
# Find a point within expandDis of nind, and closest to rnd
108+
if currentDistance <= self.expandDis:
109+
pass
110+
else:
111+
newNode.x = nearestNode.x + self.expandDis * math.cos(theta)
112+
newNode.y = nearestNode.y + self.expandDis * math.sin(theta)
113+
newNode.cost = float("inf")
114+
newNode.parent = None
111115
return newNode
112116

113117
def get_random_point(self):

0 commit comments

Comments
 (0)