Skip to content

Commit 1de0ffd

Browse files
committed
change DStar animation
1 parent 2cf4f6f commit 1de0ffd

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

PathPlanning/DStar/dstar.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def init_map(self):
6363
map_list.append(tmp)
6464
return map_list
6565

66-
def get_neighbers(self, state):
66+
def get_neighbors(self, state):
6767
state_list = []
6868
for i in [-1, 0, 1]:
6969
for j in [-1, 0, 1]:
@@ -99,18 +99,18 @@ def process_state(self):
9999
self.remove(x)
100100

101101
if k_old < x.h:
102-
for y in self.map.get_neighbers(x):
102+
for y in self.map.get_neighbors(x):
103103
if y.h <= k_old and x.h > y.h + x.cost(y):
104104
x.parent = y
105105
x.h = y.h + x.cost(y)
106106
elif k_old == x.h:
107-
for y in self.map.get_neighbers(x):
107+
for y in self.map.get_neighbors(x):
108108
if y.t == "new" or y.parent == x and y.h != x.h + x.cost(y) \
109109
or y.parent != x and y.h > x.h + x.cost(y):
110110
y.parent = x
111111
self.insert(y, x.h + x.cost(y))
112112
else:
113-
for y in self.map.get_neighbers(x):
113+
for y in self.map.get_neighbors(x):
114114
if y.t == "new" or y.parent == x and y.h != x.h + x.cost(y):
115115
y.parent = x
116116
self.insert(y, x.h + x.cost(y))
@@ -178,7 +178,7 @@ def run(self, start, end):
178178
rx.append(tmp.x)
179179
ry.append(tmp.y)
180180
if show_animation:
181-
plt.plot(rx, ry)
181+
plt.plot(rx, ry, "-r")
182182
plt.pause(0.01)
183183
if tmp.parent.state == "#":
184184
self.modify(tmp)
@@ -226,14 +226,15 @@ def main():
226226
plt.plot(ox, oy, ".k")
227227
plt.plot(start[0], start[1], "og")
228228
plt.plot(goal[0], goal[1], "xb")
229+
plt.axis("equal")
229230

230231
start = m.map[start[0]][start[1]]
231232
end = m.map[goal[0]][goal[1]]
232233
dstar = Dstar(m)
233234
rx, ry = dstar.run(start, end)
234235

235236
if show_animation:
236-
plt.plot(rx, ry)
237+
plt.plot(rx, ry, "-r")
237238
plt.show()
238239

239240

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ Its heuristic is 2D Euclid distance.
306306

307307
This is a 2D grid based the shortest path planning with D star algorithm.
308308

309-
![figure at master · nirnayroy/intelligentrobotics](https://github.com/nirnayroy/intelligent-robotics/blob/main/dstar.gif)
309+
![figure at master · nirnayroy/intelligentrobotics](https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/DStar/animation.gif)
310310

311311
The animation shows a robot finding its path avoiding an obstacle using the D* search algorithm.
312312

docs/modules/path_planning.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ Ref:
442442
.. |DWA| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/DynamicWindowApproach/animation.gif
443443
.. |Dijkstra| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/Dijkstra/animation.gif
444444
.. |astar| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/AStar/animation.gif
445-
.. |dstar| image:: https://github.com/nirnayroy/intelligent-robotics/blob/main/dstar.gif
445+
.. |dstar| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/DStar/animation.gif
446446
.. |PotentialField| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/PotentialFieldPlanning/animation.gif
447447
.. |4| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/ModelPredictiveTrajectoryGenerator/kn05animation.gif
448448
.. |5| image:: https://github.com/AtsushiSakai/PythonRobotics/raw/master/PathPlanning/ModelPredictiveTrajectoryGenerator/lookuptable.png?raw=True

0 commit comments

Comments
 (0)