diff --git a/Planning/GraphSearch/Deterministic/Dstar.py b/Planning/GraphSearch/Deterministic/Dstar.py index 488b6dc..d3b4bfc 100644 --- a/Planning/GraphSearch/Deterministic/Dstar.py +++ b/Planning/GraphSearch/Deterministic/Dstar.py @@ -88,7 +88,7 @@ def main(self): self.OPEN.put(self.s_start, self.f_value(self.s_start)) path, node_list = self.compute_shortest_path() self.plot = plotting.Plotting(self.s_start, self.s_goal) - self.plot.animation(node_list, path, "A*", show=False) + self.plot.animation(node_list, path, "D*", show=False) self.fig = plt.gcf() self.fig.canvas.mpl_connect('button_press_event', self.on_press) plt.show() diff --git a/Planning/GraphSearch/Deterministic/anytime_Dstar.py b/Planning/GraphSearch/Deterministic/anytime_Dstar.py index a579358..5eccd57 100644 --- a/Planning/GraphSearch/Deterministic/anytime_Dstar.py +++ b/Planning/GraphSearch/Deterministic/anytime_Dstar.py @@ -1,5 +1,5 @@ """ -D* +Anytime D* """ import os @@ -92,7 +92,7 @@ def main(self): self.OPEN.put(self.s_start, self.f_value(self.s_start)) path, node_list = self.compute_shortest_path() self.plot = plotting.Plotting(self.s_start, self.s_goal) - self.plot.animation(node_list, path, "A*", show=False) + self.plot.animation(node_list, path, "Anytime D*", show=False) self.fig = plt.gcf() self.fig.canvas.mpl_connect('button_press_event', self.on_press) plt.show() @@ -210,9 +210,10 @@ def on_press(self, event): old, new = self.split_old_new_nodes() plt.cla() self.plot.plot_visited(new, False, c='-b') - self.plot.animation(old, path, "D*", show=False) + self.plot.animation(old, path, "Anytime D*", show=False) self.fig.canvas.draw_idle() + def split_old_new_nodes(self): all_nodes = self.trans_node_list(self.PARENT.keys()) old = [] diff --git a/Planning/GraphSearch/Probabilistic/batch_informed_trees.py b/Planning/GraphSearch/Stochastic/batch_informed_trees.py similarity index 99% rename from Planning/GraphSearch/Probabilistic/batch_informed_trees.py rename to Planning/GraphSearch/Stochastic/batch_informed_trees.py index 12b9e94..dbe9b3e 100644 --- a/Planning/GraphSearch/Probabilistic/batch_informed_trees.py +++ b/Planning/GraphSearch/Stochastic/batch_informed_trees.py @@ -379,7 +379,7 @@ def draw_ellipse(x_center, c_best, dist, theta): t = np.arange(0, 2 * math.pi + 0.1, 0.2) x = [a * math.cos(it) for it in t] y = [b * math.sin(it) for it in t] - rot = Rot.from_euler('z', -angle).as_dcm()[0:2, 0:2] + rot = Rot.from_euler('z', -angle).as_matrix()[0:2, 0:2] fx = rot @ np.array([x, y]) px = np.array(fx[0, :] + cx).flatten() py = np.array(fx[1, :] + cy).flatten() diff --git a/Planning/GraphSearch/Probabilistic/dynamic_rrt.py b/Planning/GraphSearch/Stochastic/dynamic_rrt.py similarity index 100% rename from Planning/GraphSearch/Probabilistic/dynamic_rrt.py rename to Planning/GraphSearch/Stochastic/dynamic_rrt.py diff --git a/Planning/GraphSearch/Probabilistic/rrt.py b/Planning/GraphSearch/Stochastic/rrt.py similarity index 95% rename from Planning/GraphSearch/Probabilistic/rrt.py rename to Planning/GraphSearch/Stochastic/rrt.py index b819ca0..1a4807d 100644 --- a/Planning/GraphSearch/Probabilistic/rrt.py +++ b/Planning/GraphSearch/Stochastic/rrt.py @@ -14,7 +14,11 @@ import env, plotting, utils - +class Node: + def __init__(self, n): + self.x = n[0] + self.y = n[1] + self.parent = None class RRT: def __init__(self, s_start, s_goal, step_len, goal_sample_rate, iter_max): self.s_start = Node(s_start) @@ -97,7 +101,7 @@ def main(): x_start = (2, 2) # Starting node x_goal = (49, 24) # Goal node - rrt = RRT(x_start, x_goal, 0.5, 0.05, 10000) + rrt = RRT(x_start, x_goal, 0.5, 0.1, 10000) path = rrt.planning() if path: diff --git a/Planning/GraphSearch/Probabilistic/rrt_connect.py b/Planning/GraphSearch/Stochastic/rrt_connect.py similarity index 100% rename from Planning/GraphSearch/Probabilistic/rrt_connect.py rename to Planning/GraphSearch/Stochastic/rrt_connect.py diff --git a/Planning/GraphSearch/Probabilistic/rrt_star.py b/Planning/GraphSearch/Stochastic/rrt_star.py similarity index 94% rename from Planning/GraphSearch/Probabilistic/rrt_star.py rename to Planning/GraphSearch/Stochastic/rrt_star.py index a1355b2..188443c 100644 --- a/Planning/GraphSearch/Probabilistic/rrt_star.py +++ b/Planning/GraphSearch/Stochastic/rrt_star.py @@ -8,7 +8,7 @@ import sys import math import numpy as np - +import matplotlib.pyplot as plt sys.path.append(os.path.dirname(os.path.abspath(__file__))+'/../') import env, plotting, utils, queue @@ -49,9 +49,10 @@ def planning(self): node_near = self.nearest_neighbor(self.vertex, node_rand) node_new = self.new_state(node_near, node_rand) - if k % 500 == 0: + if k % 100 == 0: print(k) - + self.plotting.animation(self.vertex, self.path, "rrt*, N = " + str(k),show=False) + plt.pause(0.5) if node_new and not self.utils.is_collision(node_near, node_new): neighbor_index = self.find_near_neighbor(node_new) self.vertex.append(node_new) @@ -61,8 +62,8 @@ def planning(self): index = self.search_goal_parent() self.path = self.extract_path(self.vertex[index]) - - self.plotting.animation(self.vertex, self.path, "rrt*, N = " + str(self.iter_max)) + self.plotting.animation(self.vertex, self.path, "rrt*, N = " + str(self.iter_max),show=True) + def new_state(self, node_start, node_goal): dist, theta = self.get_distance_and_angle(node_start, node_goal) @@ -161,7 +162,7 @@ def main(): x_start = (18, 8) # Starting node x_goal = (37, 18) # Goal node - rrt_star = RRTStar(x_start, x_goal, 10, 0.10, 20, 2000) + rrt_star = RRTStar(x_start, x_goal, 5, 0.10, 20, 2000) rrt_star.planning() diff --git a/Planning/README.md b/Planning/README.md index ad13b2f..cb8efcf 100644 --- a/Planning/README.md +++ b/Planning/README.md @@ -1,8 +1,44 @@ Overview ---------- +Deterministic Search +-------------------- -Spline Interpolation + + + + + + + + + + + +
dijkstraA*
D*Anytime D*
+ +Stochastic Search +-------------------- + + + + + + + + + + + + + + + + +
RRTRRT Connect
RRT*Dynamic RRT
BIT*
+ + +Spline Curve ---------- @@ -14,9 +50,9 @@ Spline Interpolation
-Polynomail Trajectory ---------------------- - + + Dubins/Reeds Shepp Curve ---------- diff --git a/Planning/figure/anytime_dstar.gif b/Planning/figure/anytime_dstar.gif new file mode 100644 index 0000000..31e8554 Binary files /dev/null and b/Planning/figure/anytime_dstar.gif differ diff --git a/Planning/figure/astar.png b/Planning/figure/astar.png new file mode 100644 index 0000000..dd25a6d Binary files /dev/null and b/Planning/figure/astar.png differ diff --git a/Planning/figure/bitstar.gif b/Planning/figure/bitstar.gif new file mode 100644 index 0000000..4b7fc5f Binary files /dev/null and b/Planning/figure/bitstar.gif differ diff --git a/Planning/figure/dijkstra.png b/Planning/figure/dijkstra.png new file mode 100644 index 0000000..f7e2dea Binary files /dev/null and b/Planning/figure/dijkstra.png differ diff --git a/Planning/figure/dstar.gif b/Planning/figure/dstar.gif new file mode 100644 index 0000000..1e26bd5 Binary files /dev/null and b/Planning/figure/dstar.gif differ diff --git a/Planning/figure/dynamic_rrt.gif b/Planning/figure/dynamic_rrt.gif new file mode 100644 index 0000000..3e02f95 Binary files /dev/null and b/Planning/figure/dynamic_rrt.gif differ diff --git a/Planning/figure/rrt.gif b/Planning/figure/rrt.gif new file mode 100644 index 0000000..8b99366 Binary files /dev/null and b/Planning/figure/rrt.gif differ diff --git a/Planning/figure/rrt_connect.gif b/Planning/figure/rrt_connect.gif new file mode 100644 index 0000000..d962400 Binary files /dev/null and b/Planning/figure/rrt_connect.gif differ diff --git a/Planning/figure/rrtstar.gif b/Planning/figure/rrtstar.gif new file mode 100644 index 0000000..d39b337 Binary files /dev/null and b/Planning/figure/rrtstar.gif differ diff --git a/Planning/figure/rrtstar.png b/Planning/figure/rrtstar.png new file mode 100644 index 0000000..4342a91 Binary files /dev/null and b/Planning/figure/rrtstar.png differ