parent
195e7a0782
commit
bb70deacf8
@ -1,28 +1,35 @@ |
|||||||
from TelloModule import TelloModule |
from TelloModule import TelloModule |
||||||
import time |
import time |
||||||
|
import matplotlib.pyplot as plt |
||||||
|
import matplotlib.animation as animation |
||||||
|
|
||||||
|
|
||||||
mod = TelloModule() |
mod = TelloModule() |
||||||
|
fig = plt.figure() |
||||||
print ("\n -------- Test blocking mode --------- \n") |
plt.ion() |
||||||
for i in range(10): |
|
||||||
line = mod.get_block_dist() |
x = 100 |
||||||
print ("Test " + str(i) + |
y = 150 |
||||||
" count = " + str(line[0]) + |
line1 = plt.plot([x, 0],[0, y], c = 'b') |
||||||
" forward = " + str(line[1]) + |
line2 = plt.plot([-x, 0],[0, y], c = 'b') |
||||||
" right = " + str(line[2]) + |
line3 = plt.plot([-x, 0],[0, -y], c = 'b') |
||||||
" back = " + str(line[3]) + |
line4 = plt.plot([x, 0],[0, -y], c = 'b') |
||||||
" left = " + str(line[4]) + |
line5 = plt.plot([-x/3, x/3], [y-y/3, y-y/3], c = 'b') |
||||||
" light = " + str(line[5])) |
|
||||||
print ("\n ------ Test NON Blocking mode ------- \n") |
mod.module_init() |
||||||
mod.module_init('distance') |
|
||||||
for i in range(10): |
point = [None, None, None, None] |
||||||
print ("Test " + str(i) + |
while 1: |
||||||
" count = " + str(mod.get_count()) + |
if (point[0] != None): |
||||||
" forward = " + str(mod.get_forward_dist()) + |
for p in point: |
||||||
" right = " + str(mod.get_right_dist()) + |
p.remove() |
||||||
" back = " + str(mod.get_back_dist()) + |
point[0] = plt.scatter(0, mod.get_forward_dist(), c = 'r') |
||||||
" left = " + str(mod.get_left_dist()) + |
point[1] = plt.scatter(mod.get_right_dist(), 0, c = 'r') |
||||||
" light = " + str(mod.get_light())) |
point[2] = plt.scatter(-mod.get_left_dist(), 0, c = 'r') |
||||||
time.sleep(0.5) |
point[3] = plt.scatter(0, -mod.get_back_dist(), c = 'r') |
||||||
mod.module_deinit() |
|
||||||
print ("\n ------------ Finish Test ------------ \n") |
plt.pause(0.1) |
||||||
|
|
||||||
|
plt.ioff() |
||||||
|
plt.show() |
||||||
|
mod.module_deinit() |
@ -0,0 +1,19 @@ |
|||||||
|
from easytello import tello |
||||||
|
from TelloModule import TelloModule |
||||||
|
|
||||||
|
drone = tello.Tello() |
||||||
|
mod = TelloModule() |
||||||
|
|
||||||
|
def main(): |
||||||
|
drone.takeoff() |
||||||
|
while 1: |
||||||
|
line = mod.get_block_dist() |
||||||
|
if int(line[1]) > 400: |
||||||
|
drone.forward(20) |
||||||
|
if int(line[1]) < 300: |
||||||
|
drone.back(20) |
||||||
|
|
||||||
|
try: |
||||||
|
main() |
||||||
|
except KeyboardInterrupt: |
||||||
|
drone.land() |
Loading…
Reference in new issue