add quadrotor test

This commit is contained in:
Atsushi Sakai
2018-08-27 22:02:00 +09:00
parent 907c46467d
commit f1d68db1fa
5 changed files with 22 additions and 3 deletions

View File

@@ -11,7 +11,7 @@ from mpl_toolkits.mplot3d import Axes3D
class Quadrotor():
def __init__(self, x=0, y=0, z=0, roll=0, pitch=0, yaw=0, size=0.25):
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.p2 = np.array([-size / 2, 0, 0, 1]).T
self.p3 = np.array([0, size / 2, 0, 1]).T
@@ -20,6 +20,7 @@ class Quadrotor():
self.x_data = []
self.y_data = []
self.z_data = []
self.show_animation = show_animation
plt.ion()
@@ -38,7 +39,9 @@ class Quadrotor():
self.x_data.append(x)
self.y_data.append(y)
self.z_data.append(z)
self.plot()
if self.show_animation:
self.plot()
def transformation_matrix(self):
x = self.x

View File

Before

Width:  |  Height:  |  Size: 11 MiB

After

Width:  |  Height:  |  Size: 11 MiB

View File

@@ -9,6 +9,8 @@ import numpy as np
from Quadrotor import Quadrotor
from TrajectoryGenerator import TrajectoryGenerator
show_animation = True
# Simulation parameters
g = 9.81
m = 0.2
@@ -59,7 +61,7 @@ def quad_sim(x_c, y_c, z_c):
t = 0
q = Quadrotor(x=x_pos, y=y_pos, z=z_pos, roll=roll,
pitch=pitch, yaw=yaw, size=1)
pitch=pitch, yaw=yaw, size=1, show_animation=show_animation)
i = 0
n_run = 8

View File

@@ -0,0 +1,14 @@
from unittest import TestCase
import sys
sys.path.append("./AerialNavigation/drone_3d_trajectory_following/")
from AerialNavigation.drone_3d_trajectory_following import drone_3d_trajectory_following as m
print(__file__)
class Test(TestCase):
def test1(self):
m.show_animation = False
m.main()