Skip to content

Commit f1d68db

Browse files
committed
add quadrotor test
1 parent 907c464 commit f1d68db

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

AerialNavigation/Quadrotor.py renamed to AerialNavigation/drone_3d_trajectory_following/Quadrotor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
class Quadrotor():
14-
def __init__(self, x=0, y=0, z=0, roll=0, pitch=0, yaw=0, size=0.25):
14+
def __init__(self, x=0, y=0, z=0, roll=0, pitch=0, yaw=0, size=0.25, show_animation=True):
1515
self.p1 = np.array([size / 2, 0, 0, 1]).T
1616
self.p2 = np.array([-size / 2, 0, 0, 1]).T
1717
self.p3 = np.array([0, size / 2, 0, 1]).T
@@ -20,6 +20,7 @@ def __init__(self, x=0, y=0, z=0, roll=0, pitch=0, yaw=0, size=0.25):
2020
self.x_data = []
2121
self.y_data = []
2222
self.z_data = []
23+
self.show_animation = show_animation
2324

2425
plt.ion()
2526

@@ -38,7 +39,9 @@ def update_pose(self, x, y, z, roll, pitch, yaw):
3839
self.x_data.append(x)
3940
self.y_data.append(y)
4041
self.z_data.append(z)
41-
self.plot()
42+
43+
if self.show_animation:
44+
self.plot()
4245

4346
def transformation_matrix(self):
4447
x = self.x

AerialNavigation/quad_sim.py renamed to AerialNavigation/drone_3d_trajectory_following/drone_3d_trajectory_following.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from Quadrotor import Quadrotor
1010
from TrajectoryGenerator import TrajectoryGenerator
1111

12+
show_animation = True
13+
1214
# Simulation parameters
1315
g = 9.81
1416
m = 0.2
@@ -59,7 +61,7 @@ def quad_sim(x_c, y_c, z_c):
5961
t = 0
6062

6163
q = Quadrotor(x=x_pos, y=y_pos, z=z_pos, roll=roll,
62-
pitch=pitch, yaw=yaw, size=1)
64+
pitch=pitch, yaw=yaw, size=1, show_animation=show_animation)
6365

6466
i = 0
6567
n_run = 8
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from unittest import TestCase
2+
3+
import sys
4+
sys.path.append("./AerialNavigation/drone_3d_trajectory_following/")
5+
6+
from AerialNavigation.drone_3d_trajectory_following import drone_3d_trajectory_following as m
7+
print(__file__)
8+
9+
10+
class Test(TestCase):
11+
12+
def test1(self):
13+
m.show_animation = False
14+
m.main()

0 commit comments

Comments
 (0)