-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example.java
150 lines (115 loc) · 3.92 KB
/
Example.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package com.xpfriend.tydrone;
import org.junit.jupiter.api.Test;
public class Example {
@Test
public void testGetStates() throws Exception {
try (SimpleMain main = new SimpleMain()) {
// start communication with Tello
main.run();
for (int i = 0; i < 5; i++) {
String states = main.getStates();
System.out.println("States: " + states);
Thread.sleep(500);
}
// get more states
main.setRichStates(true);
for (int i = 0; i < 5; i++) {
String states = main.getStates();
System.out.println("States: " + states);
Thread.sleep(500);
}
}
}
@Test
public void testVideoRecording() throws Exception {
try (SimpleMain main = new SimpleMain()) {
// start communication with Tello
main.run();
// sleep 10s (because it takes a while for the video to arrive)
Thread.sleep(10000);
// start video recording
main.setRecording(true);
Thread.sleep(5000);
// stop video recording
main.setRecording(false);
Thread.sleep(1000);
}
}
@Test
public void testPicture() throws Exception {
try (SimpleMain main = new SimpleMain()) {
// start communication with Tello
main.run();
Thread.sleep(2000);
// take a picture
main.entryCommand("picture");
Thread.sleep(3000);
}
}
@Test
public void testStickCommand() throws Exception {
try (SimpleMain main = new SimpleMain()) {
// start communication with Tello
main.run();
// takeoff
main.entryCommand("takeoff");
Thread.sleep(5000);
// fly right (+rx)
main.entryCommand("stick 0.2 0 0 0 0");
Thread.sleep(2000);
// hovering
main.entryCommand("stick 0 0 0 0 0");
Thread.sleep(2000);
// fly left (-rx)
main.entryCommand("stick -0.2 0 0 0 0");
Thread.sleep(2000);
// hovering
main.entryCommand("stick 0 0 0 0 0");
Thread.sleep(2000);
// fly forward (+ry)
main.entryCommand("stick 0 0.2 0 0 0");
Thread.sleep(2000);
// hovering
main.entryCommand("stick 0 0 0 0 0");
Thread.sleep(2000);
// fly backward (-ry)
main.entryCommand("stick 0 -0.2 0 0 0");
Thread.sleep(2000);
// hovering
main.entryCommand("stick 0 0 0 0 0");
Thread.sleep(2000);
// rotate clockwise (+lx)
main.entryCommand("stick 0 0 0.5 0 0");
Thread.sleep(2000);
// hovering
main.entryCommand("stick 0 0 0 0 0");
Thread.sleep(2000);
// rotate counter clockwise (-lx)
main.entryCommand("stick 0 0 -0.5 0 0");
Thread.sleep(2000);
// hovering
main.entryCommand("stick 0 0 0 0 0");
Thread.sleep(2000);
// fly up (+ly)
main.entryCommand("stick 0 0 0 0.2 0");
Thread.sleep(2000);
// hovering
main.entryCommand("stick 0 0 0 0 0");
Thread.sleep(2000);
// fly down (-ly)
main.entryCommand("stick 0 0 0 -0.2 0");
Thread.sleep(2000);
// hovering
main.entryCommand("stick 0 0 0 0 0");
Thread.sleep(2000);
// land
main.entryCommand("land");
Thread.sleep(1000);
// I want to make sure it lands...
main.entryCommand("land");
Thread.sleep(1000);
main.entryCommand("land");
Thread.sleep(1000);
}
}
}