mirror of
https://github.com/AtsushiSakai/PythonRobotics.git
synced 2026-04-22 03:00:22 -04:00
@@ -546,6 +546,9 @@ def animation(plant, controller, dt):
|
||||
steer = math.atan2(controller.history_u_2[t] * WB / v, 1.0)
|
||||
|
||||
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")
|
||||
plot_car(x, y, yaw, steer=steer)
|
||||
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:
|
||||
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(x, y, "ob", label="trajectory")
|
||||
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:
|
||||
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(x, y, "ob", label="trajectory")
|
||||
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
|
||||
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:
|
||||
plt.plot(ox, oy, "xr", label="MPC")
|
||||
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--')
|
||||
|
||||
# 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.ylim(0, 20)
|
||||
|
||||
|
||||
@@ -166,6 +166,9 @@ def main():
|
||||
|
||||
if show_animation: # pragma: no cover
|
||||
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)
|
||||
plt.plot(cx, cy, "-r", label="course")
|
||||
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:
|
||||
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(x, y, "ob", label="trajectory")
|
||||
plt.plot(cx[target_ind], cy[target_ind], "xg", label="target")
|
||||
|
||||
@@ -185,6 +185,9 @@ def main():
|
||||
|
||||
if show_animation: # pragma: no cover
|
||||
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(x, y, "-b", label="trajectory")
|
||||
plt.plot(cx[target_idx], cy[target_idx], "xg", label="target")
|
||||
|
||||
Reference in New Issue
Block a user