add comment for stopping the simulation

This commit is contained in:
Göktuğ Karakaşlı
2019-12-14 14:44:01 +03:00
parent 25cffd70d2
commit 9ca7d8f148
53 changed files with 54 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ 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', fig.canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])

View File

@@ -567,6 +567,7 @@ 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', fig.canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])

View File

@@ -162,6 +162,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) 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)

View File

@@ -193,6 +193,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) 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)

View File

@@ -51,6 +51,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])

View File

@@ -114,6 +114,7 @@ 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', fig.canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
two_joint_arm() two_joint_arm()

View File

@@ -111,6 +111,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
ax.set_zlim(0, z_c * 2) ax.set_zlim(0, z_c * 2)

View File

@@ -213,6 +213,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])

View File

@@ -191,6 +191,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(hz[0, :], hz[1, :], ".g") plt.plot(hz[0, :], hz[1, :], ".g")

View File

@@ -233,6 +233,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) 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)

View File

@@ -230,6 +230,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])

View File

@@ -240,6 +240,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(hz[0, :], hz[1, :], ".g") plt.plot(hz[0, :], hz[1, :], ".g")

View File

@@ -124,6 +124,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.axis("equal") plt.axis("equal")

View File

@@ -73,6 +73,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) 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)

View File

@@ -133,6 +133,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
clusters.plot_cluster() clusters.plot_cluster()

View File

@@ -124,6 +124,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) 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)

View File

@@ -242,6 +242,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.axis("equal") plt.axis("equal")

View File

@@ -79,6 +79,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
if len(closed_set.keys()) % 10 == 0: if len(closed_set.keys()) % 10 == 0:

View File

@@ -534,6 +534,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
for rnd in samples: for rnd in samples:

View File

@@ -135,6 +135,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(cx, cy, "-r", label="course") plt.plot(cx, cy, "-r", label="course")

View File

@@ -69,6 +69,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
if len(closedset.keys()) % 10 == 0: if len(closedset.keys()) % 10 == 0:

View File

@@ -318,6 +318,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) 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))

View File

@@ -268,6 +268,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) 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")

View File

@@ -213,6 +213,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.pause(1.0) plt.pause(1.0)

View File

@@ -347,6 +347,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(tx, ty) plt.plot(tx, ty)

View File

@@ -213,6 +213,7 @@ 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', fig.canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
@@ -268,6 +269,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(ox, oy, "-xb") plt.plot(ox, oy, "-xb")

View File

@@ -78,6 +78,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
if len(closedset.keys()) % 10 == 0: if len(closedset.keys()) % 10 == 0:

View File

@@ -327,6 +327,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
if len(closedList.keys()) % 10 == 0: if len(closedList.keys()) % 10 == 0:

View File

@@ -267,6 +267,7 @@ class InformedRRTStar:
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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
if rnd is not None: if rnd is not None:

View File

@@ -54,6 +54,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(sx, sy, "or") plt.plot(sx, sy, "or")

View File

@@ -102,6 +102,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
if rnd is not None: if rnd is not None:

View File

@@ -98,6 +98,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(ix, iy, "*k") plt.plot(ix, iy, "*k")

View File

@@ -194,6 +194,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(current.x, current.y, "xg") plt.plot(current.x, current.y, "xg")

View File

@@ -151,6 +151,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.grid(True) plt.grid(True)

View File

@@ -138,6 +138,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
if rnd is not None: if rnd is not None:

View File

@@ -106,6 +106,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
if rnd is not None: if rnd is not None:

View File

@@ -112,6 +112,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
if rnd is not None: if rnd is not None:

View File

@@ -122,6 +122,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
if rnd is not None: if rnd is not None:

View File

@@ -395,6 +395,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) 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))

View File

@@ -185,6 +185,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.pause(0.001) plt.pause(0.001)

View File

@@ -546,6 +546,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) 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")

View File

@@ -224,6 +224,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(cx, cy, "-r", label="course") plt.plot(cx, cy, "-r", label="course")

View File

@@ -203,6 +203,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(cx, cy, "-r", label="course") plt.plot(cx, cy, "-r", label="course")

View File

@@ -429,6 +429,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
if ox is not None: if ox is not None:

View File

@@ -93,6 +93,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])

View File

@@ -166,6 +166,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) 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)

View File

@@ -149,6 +149,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(cx, cy, "-r", label="course") plt.plot(cx, cy, "-r", label="course")

View File

@@ -186,6 +186,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(cx, cy, ".r", label="course") plt.plot(cx, cy, ".r", label="course")

View File

@@ -235,6 +235,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])

View File

@@ -365,6 +365,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(RFID[:, 0], RFID[:, 1], "*k") plt.plot(RFID[:, 0], RFID[:, 1], "*k")

View File

@@ -390,6 +390,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(RFID[:, 0], RFID[:, 1], "*k") plt.plot(RFID[:, 0], RFID[:, 1], "*k")

View File

@@ -303,6 +303,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) lambda event: [exit(0) if event.key == 'escape' else None])
plt.plot(RFID[:, 0], RFID[:, 1], "*k") plt.plot(RFID[:, 0], RFID[:, 1], "*k")

View File

@@ -36,6 +36,7 @@ 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', plt.gcf().canvas.mpl_connect('key_release_event',
lambda event: [exit(0) if event.key == 'escape' else None]) 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")