Merge pull request #259 from goktug97/close_on_key

Close on key
This commit is contained in:
Atsushi Sakai
2019-12-14 21:33:26 +09:00
committed by GitHub
53 changed files with 168 additions and 8 deletions

View File

@@ -8,7 +8,6 @@ from math import cos, sin
import numpy as np
import matplotlib.pyplot as plt
class Quadrotor():
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
@@ -24,6 +23,10 @@ class Quadrotor():
if self.show_animation:
plt.ion()
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.update_pose(x, y, z, roll, pitch, yaw)
@@ -81,4 +84,4 @@ class Quadrotor():
plt.ylim(-5, 5)
self.ax.set_zlim(0, 10)
plt.pause(0.001)
plt.pause(0.001)

View File

@@ -567,6 +567,9 @@ def plot_animation(X, U): # pragma: no cover
fig = plt.figure()
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):
plt.cla()