mirror of
https://github.com/AtsushiSakai/PythonRobotics.git
synced 2026-02-11 10:38:27 -05:00
@@ -8,7 +8,6 @@ from math import cos, sin
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
|
||||||
class Quadrotor():
|
class Quadrotor():
|
||||||
def __init__(self, x=0, y=0, z=0, roll=0, pitch=0, yaw=0, size=0.25, show_animation=True):
|
def __init__(self, x=0, y=0, z=0, roll=0, pitch=0, yaw=0, size=0.25, show_animation=True):
|
||||||
self.p1 = np.array([size / 2, 0, 0, 1]).T
|
self.p1 = np.array([size / 2, 0, 0, 1]).T
|
||||||
@@ -24,6 +23,10 @@ class Quadrotor():
|
|||||||
if self.show_animation:
|
if self.show_animation:
|
||||||
plt.ion()
|
plt.ion()
|
||||||
fig = plt.figure()
|
fig = plt.figure()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
fig.canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
|
|
||||||
self.ax = fig.add_subplot(111, projection='3d')
|
self.ax = fig.add_subplot(111, projection='3d')
|
||||||
|
|
||||||
self.update_pose(x, y, z, roll, pitch, yaw)
|
self.update_pose(x, y, z, roll, pitch, yaw)
|
||||||
|
|||||||
@@ -567,6 +567,9 @@ def plot_animation(X, U): # pragma: no cover
|
|||||||
|
|
||||||
fig = plt.figure()
|
fig = plt.figure()
|
||||||
ax = fig.gca(projection='3d')
|
ax = fig.gca(projection='3d')
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
fig.canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
|
|
||||||
for k in range(K):
|
for k in range(K):
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
|||||||
@@ -162,6 +162,9 @@ def astar_torus(grid, start_node, goal_node):
|
|||||||
for i in range(1, len(route)):
|
for i in range(1, len(route)):
|
||||||
grid[route[i]] = 6
|
grid[route[i]] = 6
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.imshow(grid, cmap=cmap, norm=norm, interpolation=None)
|
plt.imshow(grid, cmap=cmap, norm=norm, interpolation=None)
|
||||||
plt.show()
|
plt.show()
|
||||||
plt.pause(1e-2)
|
plt.pause(1e-2)
|
||||||
|
|||||||
@@ -193,6 +193,9 @@ def astar_torus(grid, start_node, goal_node):
|
|||||||
for i in range(1, len(route)):
|
for i in range(1, len(route)):
|
||||||
grid[route[i]] = 6
|
grid[route[i]] = 6
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.imshow(grid, cmap=cmap, norm=norm, interpolation=None)
|
plt.imshow(grid, cmap=cmap, norm=norm, interpolation=None)
|
||||||
plt.show()
|
plt.show()
|
||||||
plt.pause(1e-2)
|
plt.pause(1e-2)
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ class NLinkArm(object):
|
|||||||
|
|
||||||
def plot(self): # pragma: no cover
|
def plot(self): # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
|
|
||||||
for i in range(self.n_links + 1):
|
for i in range(self.n_links + 1):
|
||||||
if i is not self.n_links:
|
if i is not self.n_links:
|
||||||
|
|||||||
@@ -114,6 +114,9 @@ def animation():
|
|||||||
def main(): # pragma: no cover
|
def main(): # pragma: no cover
|
||||||
fig = plt.figure()
|
fig = plt.figure()
|
||||||
fig.canvas.mpl_connect("button_press_event", click)
|
fig.canvas.mpl_connect("button_press_event", click)
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
fig.canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
two_joint_arm()
|
two_joint_arm()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ class BipedalPlanner(object):
|
|||||||
if c > len(com_trajectory_for_plot):
|
if c > len(com_trajectory_for_plot):
|
||||||
# set up plotter
|
# set up plotter
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
ax.set_zlim(0, z_c * 2)
|
ax.set_zlim(0, z_c * 2)
|
||||||
ax.set_aspect('equal', 'datalim')
|
ax.set_aspect('equal', 'datalim')
|
||||||
|
|
||||||
|
|||||||
@@ -213,6 +213,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation:
|
if show_animation:
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
|
|
||||||
for i in range(len(z[:, 0])):
|
for i in range(len(z[:, 0])):
|
||||||
plt.plot([xTrue[0, 0], z[i, 2]], [xTrue[1, 0], z[i, 3]], "-k")
|
plt.plot([xTrue[0, 0], z[i, 2]], [xTrue[1, 0], z[i, 3]], "-k")
|
||||||
|
|||||||
@@ -191,6 +191,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation:
|
if show_animation:
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(hz[0, :], hz[1, :], ".g")
|
plt.plot(hz[0, :], hz[1, :], ".g")
|
||||||
plt.plot(hxTrue[0, :].flatten(),
|
plt.plot(hxTrue[0, :].flatten(),
|
||||||
hxTrue[1, :].flatten(), "-b")
|
hxTrue[1, :].flatten(), "-b")
|
||||||
|
|||||||
@@ -233,6 +233,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation:
|
if show_animation:
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
draw_heat_map(grid_map.data, mx, my)
|
draw_heat_map(grid_map.data, mx, my)
|
||||||
plt.plot(xTrue[0, :], xTrue[1, :], "xr")
|
plt.plot(xTrue[0, :], xTrue[1, :], "xr")
|
||||||
plt.plot(RF_ID[:, 0], RF_ID[:, 1], ".k")
|
plt.plot(RF_ID[:, 0], RF_ID[:, 1], ".k")
|
||||||
|
|||||||
@@ -230,6 +230,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation:
|
if show_animation:
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
|
|
||||||
for i in range(len(z[:, 0])):
|
for i in range(len(z[:, 0])):
|
||||||
plt.plot([xTrue[0, 0], z[i, 1]], [xTrue[1, 0], z[i, 2]], "-k")
|
plt.plot([xTrue[0, 0], z[i, 1]], [xTrue[1, 0], z[i, 2]], "-k")
|
||||||
|
|||||||
@@ -240,6 +240,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation:
|
if show_animation:
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(hz[0, :], hz[1, :], ".g")
|
plt.plot(hz[0, :], hz[1, :], ".g")
|
||||||
plt.plot(np.array(hxTrue[0, :]).flatten(),
|
plt.plot(np.array(hxTrue[0, :]).flatten(),
|
||||||
np.array(hxTrue[1, :]).flatten(), "-b")
|
np.array(hxTrue[1, :]).flatten(), "-b")
|
||||||
|
|||||||
@@ -124,6 +124,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.axis("equal")
|
plt.axis("equal")
|
||||||
plt.plot(0.0, 0.0, "*r")
|
plt.plot(0.0, 0.0, "*r")
|
||||||
plot_circle(cx, cy, cr)
|
plot_circle(cx, cy, cr)
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
draw_heatmap(gmap, minx, maxx, miny, maxy, xyreso)
|
draw_heatmap(gmap, minx, maxx, miny, maxy, xyreso)
|
||||||
plt.plot(ox, oy, "xr")
|
plt.plot(ox, oy, "xr")
|
||||||
plt.plot(0.0, 0.0, "ob")
|
plt.plot(0.0, 0.0, "ob")
|
||||||
|
|||||||
@@ -133,8 +133,10 @@ def main():
|
|||||||
# for animation
|
# for animation
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
clusters.plot_cluster()
|
clusters.plot_cluster()
|
||||||
|
|
||||||
plt.plot(cx, cy, "or")
|
plt.plot(cx, cy, "or")
|
||||||
plt.xlim(-2.0, 10.0)
|
plt.xlim(-2.0, 10.0)
|
||||||
plt.ylim(-2.0, 10.0)
|
plt.ylim(-2.0, 10.0)
|
||||||
|
|||||||
@@ -124,6 +124,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
draw_heatmap(pmap, minx, maxx, miny, maxy, xyreso)
|
draw_heatmap(pmap, minx, maxx, miny, maxy, xyreso)
|
||||||
plt.plot(ox, oy, "xr")
|
plt.plot(ox, oy, "xr")
|
||||||
plt.plot(0.0, 0.0, "ob")
|
plt.plot(0.0, 0.0, "ob")
|
||||||
|
|||||||
@@ -242,6 +242,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.axis("equal")
|
plt.axis("equal")
|
||||||
plt.plot(0.0, 0.0, "*r")
|
plt.plot(0.0, 0.0, "*r")
|
||||||
v1.plot()
|
v1.plot()
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ class AStarPlanner:
|
|||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.plot(self.calc_grid_position(current.x, self.minx),
|
plt.plot(self.calc_grid_position(current.x, self.minx),
|
||||||
self.calc_grid_position(current.y, self.miny), "xc")
|
self.calc_grid_position(current.y, self.miny), "xc")
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
if len(closed_set.keys()) % 10 == 0:
|
if len(closed_set.keys()) % 10 == 0:
|
||||||
plt.pause(0.001)
|
plt.pause(0.001)
|
||||||
|
|
||||||
|
|||||||
@@ -534,6 +534,9 @@ class BITStar(object):
|
|||||||
def draw_graph(self, xCenter=None, cBest=None, cMin=None, etheta=None,
|
def draw_graph(self, xCenter=None, cBest=None, cMin=None, etheta=None,
|
||||||
samples=None, start=None, end=None):
|
samples=None, start=None, end=None):
|
||||||
plt.clf()
|
plt.clf()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
for rnd in samples:
|
for rnd in samples:
|
||||||
if rnd is not None:
|
if rnd is not None:
|
||||||
plt.plot(rnd[0], rnd[1], "^k")
|
plt.plot(rnd[0], rnd[1], "^k")
|
||||||
|
|||||||
@@ -135,6 +135,9 @@ def closed_loop_prediction(cx, cy, cyaw, speed_profile, goal):
|
|||||||
|
|
||||||
if target_ind % 1 == 0 and animation: # pragma: no cover
|
if target_ind % 1 == 0 and animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(cx, cy, "-r", label="course")
|
plt.plot(cx, cy, "-r", label="course")
|
||||||
plt.plot(x, y, "ob", label="trajectory")
|
plt.plot(x, y, "ob", label="trajectory")
|
||||||
plt.plot(cx[target_ind], cy[target_ind], "xg", label="target")
|
plt.plot(cx[target_ind], cy[target_ind], "xg", label="target")
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ class Dijkstra:
|
|||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.plot(self.calc_position(current.x, self.minx),
|
plt.plot(self.calc_position(current.x, self.minx),
|
||||||
self.calc_position(current.y, self.miny), "xc")
|
self.calc_position(current.y, self.miny), "xc")
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
if len(closedset.keys()) % 10 == 0:
|
if len(closedset.keys()) % 10 == 0:
|
||||||
plt.pause(0.001)
|
plt.pause(0.001)
|
||||||
|
|
||||||
|
|||||||
@@ -318,6 +318,9 @@ def test():
|
|||||||
|
|
||||||
if show_animation:
|
if show_animation:
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(px, py, label="final course " + str(mode))
|
plt.plot(px, py, label="final course " + str(mode))
|
||||||
|
|
||||||
# plotting
|
# plotting
|
||||||
|
|||||||
@@ -268,6 +268,9 @@ def main(gx=10.0, gy=10.0, robot_type=RobotType.circle):
|
|||||||
|
|
||||||
if show_animation:
|
if show_animation:
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(predicted_trajectory[:, 0], predicted_trajectory[:, 1], "-g")
|
plt.plot(predicted_trajectory[:, 0], predicted_trajectory[:, 1], "-g")
|
||||||
plt.plot(x[0], x[1], "xr")
|
plt.plot(x[0], x[1], "xr")
|
||||||
plt.plot(goal[0], goal[1], "xb")
|
plt.plot(goal[0], goal[1], "xb")
|
||||||
|
|||||||
@@ -213,6 +213,9 @@ def test1():
|
|||||||
if show_animation:
|
if show_animation:
|
||||||
# plot the path
|
# plot the path
|
||||||
plt.plot(pos[0, :], pos[1, :])
|
plt.plot(pos[0, :], pos[1, :])
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.pause(1.0)
|
plt.pause(1.0)
|
||||||
|
|
||||||
if show_animation:
|
if show_animation:
|
||||||
|
|||||||
@@ -347,6 +347,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(tx, ty)
|
plt.plot(tx, ty)
|
||||||
plt.plot(ob[:, 0], ob[:, 1], "xk")
|
plt.plot(ob[:, 0], ob[:, 1], "xk")
|
||||||
plt.plot(path.x[1:], path.y[1:], "-or")
|
plt.plot(path.x[1:], path.y[1:], "-or")
|
||||||
|
|||||||
@@ -213,6 +213,9 @@ def sweep_path_search(sweep_searcher, gmap, grid_search_animation=False):
|
|||||||
|
|
||||||
if grid_search_animation:
|
if grid_search_animation:
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
fig.canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
cxind, cyind = sweep_searcher.move_target_grid(cxind, cyind, gmap)
|
cxind, cyind = sweep_searcher.move_target_grid(cxind, cyind, gmap)
|
||||||
@@ -266,6 +269,9 @@ def planning_animation(ox, oy, reso): # pragma: no cover
|
|||||||
if do_animation:
|
if do_animation:
|
||||||
for ipx, ipy in zip(px, py):
|
for ipx, ipy in zip(px, py):
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(ox, oy, "-xb")
|
plt.plot(ox, oy, "-xb")
|
||||||
plt.plot(px, py, "-r")
|
plt.plot(px, py, "-r")
|
||||||
plt.plot(ipx, ipy, "or")
|
plt.plot(ipx, ipy, "or")
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ def dp_planning(sx, sy, gx, gy, ox, oy, reso, rr):
|
|||||||
# show graph
|
# show graph
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.plot(current.x * reso, current.y * reso, "xc")
|
plt.plot(current.x * reso, current.y * reso, "xc")
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
if len(closedset.keys()) % 10 == 0:
|
if len(closedset.keys()) % 10 == 0:
|
||||||
plt.pause(0.001)
|
plt.pause(0.001)
|
||||||
|
|
||||||
|
|||||||
@@ -327,6 +327,9 @@ def hybrid_a_star_planning(start, goal, ox, oy, xyreso, yawreso):
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.plot(current.xlist[-1], current.ylist[-1], "xc")
|
plt.plot(current.xlist[-1], current.ylist[-1], "xc")
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
if len(closedList.keys()) % 10 == 0:
|
if len(closedList.keys()) % 10 == 0:
|
||||||
plt.pause(0.001)
|
plt.pause(0.001)
|
||||||
|
|
||||||
|
|||||||
@@ -266,8 +266,10 @@ class InformedRRTStar:
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
def draw_graph(self, xCenter=None, cBest=None, cMin=None, etheta=None, rnd=None):
|
def draw_graph(self, xCenter=None, cBest=None, cMin=None, etheta=None, rnd=None):
|
||||||
|
|
||||||
plt.clf()
|
plt.clf()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
if rnd is not None:
|
if rnd is not None:
|
||||||
plt.plot(rnd[0], rnd[1], "^k")
|
plt.plot(rnd[0], rnd[1], "^k")
|
||||||
if cBest != float('inf'):
|
if cBest != float('inf'):
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ class LQRPlanner:
|
|||||||
|
|
||||||
# animation
|
# animation
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(sx, sy, "or")
|
plt.plot(sx, sy, "or")
|
||||||
plt.plot(gx, gy, "ob")
|
plt.plot(gx, gy, "ob")
|
||||||
plt.plot(rx, ry, "-r")
|
plt.plot(rx, ry, "-r")
|
||||||
|
|||||||
@@ -102,6 +102,9 @@ class LQRRRTStar(RRTStar):
|
|||||||
|
|
||||||
def draw_graph(self, rnd=None):
|
def draw_graph(self, rnd=None):
|
||||||
plt.clf()
|
plt.clf()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
if rnd is not None:
|
if rnd is not None:
|
||||||
plt.plot(rnd.x, rnd.y, "^k")
|
plt.plot(rnd.x, rnd.y, "^k")
|
||||||
for node in self.node_list:
|
for node in self.node_list:
|
||||||
|
|||||||
@@ -98,6 +98,9 @@ def potential_field_planning(sx, sy, gx, gy, ox, oy, reso, rr):
|
|||||||
|
|
||||||
if show_animation:
|
if show_animation:
|
||||||
draw_heatmap(pmap)
|
draw_heatmap(pmap)
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(ix, iy, "*k")
|
plt.plot(ix, iy, "*k")
|
||||||
plt.plot(gix, giy, "*m")
|
plt.plot(gix, giy, "*m")
|
||||||
|
|
||||||
|
|||||||
@@ -194,6 +194,9 @@ def dijkstra_planning(sx, sy, gx, gy, ox, oy, rr, road_map, sample_x, sample_y):
|
|||||||
|
|
||||||
# show graph
|
# show graph
|
||||||
if show_animation and len(closedset.keys()) % 2 == 0:
|
if show_animation and len(closedset.keys()) % 2 == 0:
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(current.x, current.y, "xg")
|
plt.plot(current.x, current.y, "xg")
|
||||||
plt.pause(0.001)
|
plt.pause(0.001)
|
||||||
|
|
||||||
|
|||||||
@@ -151,6 +151,9 @@ def quintic_polynomials_planner(sx, sy, syaw, sv, sa, gx, gy, gyaw, gv, ga, max_
|
|||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
for i, _ in enumerate(time):
|
for i, _ in enumerate(time):
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.grid(True)
|
plt.grid(True)
|
||||||
plt.axis("equal")
|
plt.axis("equal")
|
||||||
plot_arrow(sx, sy, syaw)
|
plot_arrow(sx, sy, syaw)
|
||||||
|
|||||||
@@ -138,6 +138,9 @@ class RRT:
|
|||||||
|
|
||||||
def draw_graph(self, rnd=None):
|
def draw_graph(self, rnd=None):
|
||||||
plt.clf()
|
plt.clf()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
if rnd is not None:
|
if rnd is not None:
|
||||||
plt.plot(rnd.x, rnd.y, "^k")
|
plt.plot(rnd.x, rnd.y, "^k")
|
||||||
for node in self.node_list:
|
for node in self.node_list:
|
||||||
|
|||||||
@@ -106,6 +106,9 @@ class RRTDubins(RRT):
|
|||||||
|
|
||||||
def draw_graph(self, rnd=None): # pragma: no cover
|
def draw_graph(self, rnd=None): # pragma: no cover
|
||||||
plt.clf()
|
plt.clf()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
if rnd is not None:
|
if rnd is not None:
|
||||||
plt.plot(rnd.x, rnd.y, "^k")
|
plt.plot(rnd.x, rnd.y, "^k")
|
||||||
for node in self.node_list:
|
for node in self.node_list:
|
||||||
|
|||||||
@@ -112,6 +112,9 @@ class RRTStarDubins(RRTStar):
|
|||||||
|
|
||||||
def draw_graph(self, rnd=None):
|
def draw_graph(self, rnd=None):
|
||||||
plt.clf()
|
plt.clf()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
if rnd is not None:
|
if rnd is not None:
|
||||||
plt.plot(rnd.x, rnd.y, "^k")
|
plt.plot(rnd.x, rnd.y, "^k")
|
||||||
for node in self.node_list:
|
for node in self.node_list:
|
||||||
|
|||||||
@@ -122,6 +122,9 @@ class RRTStarReedsShepp(RRTStar):
|
|||||||
|
|
||||||
def draw_graph(self, rnd=None):
|
def draw_graph(self, rnd=None):
|
||||||
plt.clf()
|
plt.clf()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
if rnd is not None:
|
if rnd is not None:
|
||||||
plt.plot(rnd.x, rnd.y, "^k")
|
plt.plot(rnd.x, rnd.y, "^k")
|
||||||
for node in self.node_list:
|
for node in self.node_list:
|
||||||
|
|||||||
@@ -395,6 +395,9 @@ def test():
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(px, py, label="final course " + str(mode))
|
plt.plot(px, py, label="final course " + str(mode))
|
||||||
|
|
||||||
# plotting
|
# plotting
|
||||||
|
|||||||
@@ -185,6 +185,9 @@ def dijkstra_planning(sx, sy, gx, gy, ox, oy, rr, road_map, sample_x, sample_y):
|
|||||||
# show graph
|
# show graph
|
||||||
if show_animation and len(closedset.keys()) % 2 == 0: # pragma: no cover
|
if show_animation and len(closedset.keys()) % 2 == 0: # pragma: no cover
|
||||||
plt.plot(current.x, current.y, "xg")
|
plt.plot(current.x, current.y, "xg")
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.pause(0.001)
|
plt.pause(0.001)
|
||||||
|
|
||||||
if c_id == (len(road_map) - 1):
|
if c_id == (len(road_map) - 1):
|
||||||
|
|||||||
@@ -546,6 +546,9 @@ def animation(plant, controller, dt):
|
|||||||
steer = math.atan2(controller.history_u_2[t] * WB / v, 1.0)
|
steer = math.atan2(controller.history_u_2[t] * WB / v, 1.0)
|
||||||
|
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(plant.history_x, plant.history_y, "-r", label="trajectory")
|
plt.plot(plant.history_x, plant.history_y, "-r", label="trajectory")
|
||||||
plot_car(x, y, yaw, steer=steer)
|
plot_car(x, y, yaw, steer=steer)
|
||||||
plt.axis("equal")
|
plt.axis("equal")
|
||||||
|
|||||||
@@ -224,6 +224,9 @@ def do_simulation(cx, cy, cyaw, ck, speed_profile, goal):
|
|||||||
|
|
||||||
if target_ind % 1 == 0 and show_animation:
|
if target_ind % 1 == 0 and show_animation:
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(cx, cy, "-r", label="course")
|
plt.plot(cx, cy, "-r", label="course")
|
||||||
plt.plot(x, y, "ob", label="trajectory")
|
plt.plot(x, y, "ob", label="trajectory")
|
||||||
plt.plot(cx[target_ind], cy[target_ind], "xg", label="target")
|
plt.plot(cx[target_ind], cy[target_ind], "xg", label="target")
|
||||||
|
|||||||
@@ -203,6 +203,9 @@ def closed_loop_prediction(cx, cy, cyaw, ck, speed_profile, goal):
|
|||||||
|
|
||||||
if target_ind % 1 == 0 and show_animation:
|
if target_ind % 1 == 0 and show_animation:
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(cx, cy, "-r", label="course")
|
plt.plot(cx, cy, "-r", label="course")
|
||||||
plt.plot(x, y, "ob", label="trajectory")
|
plt.plot(x, y, "ob", label="trajectory")
|
||||||
plt.plot(cx[target_ind], cy[target_ind], "xg", label="target")
|
plt.plot(cx[target_ind], cy[target_ind], "xg", label="target")
|
||||||
|
|||||||
@@ -429,6 +429,9 @@ def do_simulation(cx, cy, cyaw, ck, sp, dl, initial_state):
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
if ox is not None:
|
if ox is not None:
|
||||||
plt.plot(ox, oy, "xr", label="MPC")
|
plt.plot(ox, oy, "xr", label="MPC")
|
||||||
plt.plot(cx, cy, "-r", label="course")
|
plt.plot(cx, cy, "-r", label="course")
|
||||||
|
|||||||
@@ -93,6 +93,10 @@ def plot_vehicle(x, y, theta, x_traj, y_traj): # pragma: no cover
|
|||||||
|
|
||||||
plt.plot(x_traj, y_traj, 'b--')
|
plt.plot(x_traj, y_traj, 'b--')
|
||||||
|
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
|
|
||||||
plt.xlim(0, 20)
|
plt.xlim(0, 20)
|
||||||
plt.ylim(0, 20)
|
plt.ylim(0, 20)
|
||||||
|
|
||||||
|
|||||||
@@ -166,6 +166,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plot_arrow(state.x, state.y, state.yaw)
|
plot_arrow(state.x, state.y, state.yaw)
|
||||||
plt.plot(cx, cy, "-r", label="course")
|
plt.plot(cx, cy, "-r", label="course")
|
||||||
plt.plot(x, y, "-b", label="trajectory")
|
plt.plot(x, y, "-b", label="trajectory")
|
||||||
|
|||||||
@@ -149,6 +149,9 @@ def closed_loop_prediction(cx, cy, cyaw, ck, speed_profile, goal):
|
|||||||
|
|
||||||
if target_ind % 1 == 0 and show_animation:
|
if target_ind % 1 == 0 and show_animation:
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(cx, cy, "-r", label="course")
|
plt.plot(cx, cy, "-r", label="course")
|
||||||
plt.plot(x, y, "ob", label="trajectory")
|
plt.plot(x, y, "ob", label="trajectory")
|
||||||
plt.plot(cx[target_ind], cy[target_ind], "xg", label="target")
|
plt.plot(cx[target_ind], cy[target_ind], "xg", label="target")
|
||||||
|
|||||||
@@ -185,6 +185,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(cx, cy, ".r", label="course")
|
plt.plot(cx, cy, ".r", label="course")
|
||||||
plt.plot(x, y, "-b", label="trajectory")
|
plt.plot(x, y, "-b", label="trajectory")
|
||||||
plt.plot(cx[target_idx], cy[target_idx], "xg", label="target")
|
plt.plot(cx[target_idx], cy[target_idx], "xg", label="target")
|
||||||
|
|||||||
@@ -235,6 +235,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
|
|
||||||
plt.plot(RFID[:, 0], RFID[:, 1], "*k")
|
plt.plot(RFID[:, 0], RFID[:, 1], "*k")
|
||||||
plt.plot(xEst[0], xEst[1], ".r")
|
plt.plot(xEst[0], xEst[1], ".r")
|
||||||
|
|||||||
@@ -365,6 +365,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(RFID[:, 0], RFID[:, 1], "*k")
|
plt.plot(RFID[:, 0], RFID[:, 1], "*k")
|
||||||
|
|
||||||
for i in range(N_PARTICLE):
|
for i in range(N_PARTICLE):
|
||||||
|
|||||||
@@ -390,6 +390,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(RFID[:, 0], RFID[:, 1], "*k")
|
plt.plot(RFID[:, 0], RFID[:, 1], "*k")
|
||||||
|
|
||||||
for iz in range(len(z[:, 0])):
|
for iz in range(len(z[:, 0])):
|
||||||
|
|||||||
@@ -303,7 +303,9 @@ def main():
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(RFID[:, 0], RFID[:, 1], "*k")
|
plt.plot(RFID[:, 0], RFID[:, 1], "*k")
|
||||||
|
|
||||||
plt.plot(hxTrue[0, :].flatten(),
|
plt.plot(hxTrue[0, :].flatten(),
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ def icp_matching(previous_points, current_points):
|
|||||||
|
|
||||||
if show_animation: # pragma: no cover
|
if show_animation: # pragma: no cover
|
||||||
plt.cla()
|
plt.cla()
|
||||||
|
# for stopping simulation with the esc key.
|
||||||
|
plt.gcf().canvas.mpl_connect('key_release_event',
|
||||||
|
lambda event: [exit(0) if event.key == 'escape' else None])
|
||||||
plt.plot(previous_points[0, :], previous_points[1, :], ".r")
|
plt.plot(previous_points[0, :], previous_points[1, :], ".r")
|
||||||
plt.plot(current_points[0, :], current_points[1, :], ".b")
|
plt.plot(current_points[0, :], current_points[1, :], ".b")
|
||||||
plt.plot(0.0, 0.0, "xr")
|
plt.plot(0.0, 0.0, "xr")
|
||||||
|
|||||||
Reference in New Issue
Block a user