|
14 | 14 |
|
15 | 15 | show_animation = True |
16 | 16 |
|
| 17 | +class Node(): |
| 18 | + |
| 19 | + def __init__(self, x, y): |
| 20 | + self.x = x |
| 21 | + self.y = y |
| 22 | + self.cost = 0.0 |
| 23 | + self.parent = None |
| 24 | + |
17 | 25 | class BITStar(): |
18 | 26 |
|
19 | | - def __init__(self, star, goal, |
| 27 | + def __init__(self, start, goal, |
20 | 28 | obstacleList, randArea, |
21 | | - expandDis=0.5, goalSampleRate=10, maxIter=200): |
| 29 | + expandDis=0.5, goalSampleRate=10, maxIter=200, eta): |
| 30 | + self.start = Node(start[0], start[1]) |
| 31 | + self.goal = Node(goal[0], goal[1]) |
| 32 | + self.minrand = randArea[0] |
| 33 | + self.maxrand = randArea[1] |
| 34 | + self.expandDis = expandDis |
| 35 | + self.goalSampleRate = goalSampleRate |
| 36 | + self.maxIter = maxIter |
| 37 | + self.obstacleList = obstacleList |
| 38 | + self.samples = dict() |
| 39 | + self.g_scores = dict() |
| 40 | + self.f_scores = dict() |
| 41 | + self.r = float('inf') |
| 42 | + self.eta = eta # tunable parameter |
| 43 | + self.unit_ball_measure = #TODO |
| 44 | + |
| 45 | + def plan(self, animation=True): |
22 | 46 |
|
| 47 | + self.nodeList = [self.start] |
23 | 48 |
|
24 | 49 |
|
25 | 50 |
|
26 | 51 |
|
27 | 52 |
|
28 | | - def plan(self, animation=True): |
29 | 53 |
|
30 | 54 |
|
31 | 55 | def expandVertex(self, vertex): |
32 | 56 |
|
33 | 57 | def prune(self, c): |
34 | 58 |
|
35 | 59 | def radius(self, q): |
36 | | - |
| 60 | + dim = len(start) #dimensions |
| 61 | + space_measure = self.minrand * self.maxrand # volume of the space |
| 62 | + |
| 63 | + min_radius = self.eta * 2.0 * pow((1.0 + 1.0/dim) * |
| 64 | + (space_measure/self.unit_ball_measure), 1.0/dim) |
| 65 | + return min_radius * pow(numpy.log(q)/q, 1/dim) |
| 66 | + |
| 67 | + # Return the closest sample |
37 | 68 | def getNearestSample(self): |
38 | 69 |
|
| 70 | + # Sample free space confined in the radius of ball R |
39 | 71 | def sample(self, m, cMax): |
40 | 72 |
|
| 73 | + # Sample point in a unit ball |
41 | 74 | def sampleUnitBall(self, m): |
42 | 75 |
|
43 | 76 | def bestVertexQueueValue(self): |
|
0 commit comments