From 1de0ffddb1ea11396a019403bbb986c8df8e0bdd Mon Sep 17 00:00:00 2001 From: Atsushi Sakai Date: Sat, 15 May 2021 15:21:15 +0900 Subject: [PATCH] change DStar animation --- PathPlanning/DStar/dstar.py | 13 +++++++------ README.md | 2 +- docs/modules/path_planning.rst | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/PathPlanning/DStar/dstar.py b/PathPlanning/DStar/dstar.py index bc7e7c96..e01508b3 100644 --- a/PathPlanning/DStar/dstar.py +++ b/PathPlanning/DStar/dstar.py @@ -63,7 +63,7 @@ class Map: map_list.append(tmp) return map_list - def get_neighbers(self, state): + def get_neighbors(self, state): state_list = [] for i in [-1, 0, 1]: for j in [-1, 0, 1]: @@ -99,18 +99,18 @@ class Dstar: self.remove(x) if k_old < x.h: - for y in self.map.get_neighbers(x): + for y in self.map.get_neighbors(x): if y.h <= k_old and x.h > y.h + x.cost(y): x.parent = y x.h = y.h + x.cost(y) elif k_old == x.h: - for y in self.map.get_neighbers(x): + for y in self.map.get_neighbors(x): if y.t == "new" or y.parent == x and y.h != x.h + x.cost(y) \ or y.parent != x and y.h > x.h + x.cost(y): y.parent = x self.insert(y, x.h + x.cost(y)) else: - for y in self.map.get_neighbers(x): + for y in self.map.get_neighbors(x): if y.t == "new" or y.parent == x and y.h != x.h + x.cost(y): y.parent = x self.insert(y, x.h + x.cost(y)) @@ -178,7 +178,7 @@ class Dstar: rx.append(tmp.x) ry.append(tmp.y) if show_animation: - plt.plot(rx, ry) + plt.plot(rx, ry, "-r") plt.pause(0.01) if tmp.parent.state == "#": self.modify(tmp) @@ -226,6 +226,7 @@ def main(): plt.plot(ox, oy, ".k") plt.plot(start[0], start[1], "og") plt.plot(goal[0], goal[1], "xb") + plt.axis("equal") start = m.map[start[0]][start[1]] end = m.map[goal[0]][goal[1]] @@ -233,7 +234,7 @@ def main(): rx, ry = dstar.run(start, end) if show_animation: - plt.plot(rx, ry) + plt.plot(rx, ry, "-r") plt.show() diff --git a/README.md b/README.md index ca9e6192..fac8b53d 100644 --- a/README.md +++ b/README.md @@ -306,7 +306,7 @@ Its heuristic is 2D Euclid distance. This is a 2D grid based the shortest path planning with D star algorithm. -![figure at master · nirnayroy/intelligentrobotics](https://github.com/nirnayroy/intelligent-robotics/blob/main/dstar.gif) +![figure at master · nirnayroy/intelligentrobotics](https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/DStar/animation.gif) The animation shows a robot finding its path avoiding an obstacle using the D* search algorithm. diff --git a/docs/modules/path_planning.rst b/docs/modules/path_planning.rst index a0bdd455..cfe7b6ad 100644 --- a/docs/modules/path_planning.rst +++ b/docs/modules/path_planning.rst @@ -442,7 +442,7 @@ Ref: .. |DWA| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/DynamicWindowApproach/animation.gif .. |Dijkstra| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/Dijkstra/animation.gif .. |astar| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/AStar/animation.gif -.. |dstar| image:: https://github.com/nirnayroy/intelligent-robotics/blob/main/dstar.gif +.. |dstar| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/DStar/animation.gif .. |PotentialField| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/PotentialFieldPlanning/animation.gif .. |4| image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/ModelPredictiveTrajectoryGenerator/kn05animation.gif .. |5| image:: https://github.com/AtsushiSakai/PythonRobotics/raw/master/PathPlanning/ModelPredictiveTrajectoryGenerator/lookuptable.png?raw=True