-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswarm.py
48 lines (40 loc) · 862 Bytes
/
swarm.py
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
import sys, time
from djitellopy import TelloSwarm
swarm = TelloSwarm.fromFile("ips.txt")
if len(swarm) != 4:
print("This script was made to be run with four tellos!")
exit(1)
swarm.connect()
swarm.set_speed(80)
swarm.takeoff()
swarm.move_up(100)
def workerFunc(i, tello):
tello.move_left(150 - 50 * i)
swarm.sync()
tello.move_forward(i * 30)
swarm.sync()
if i == 0:
swarm.sync()
swarm.sync()
tello.rotate_clockwise(90)
elif i == 1:
tello.move_back(150)
swarm.sync()
tello.move_left(50)
swarm.sync()
elif i == 2:
tello.move_back(150)
swarm.sync()
tello.move_right(50)
swarm.sync()
tello.rotate_counter_clockwise(90)
else: # i == 3
swarm.sync()
swarm.sync()
tello.rotate_clockwise(180)
#swarm.parallel(workerFunc)
for i in range(0, 5):
swarm.move_forward(150)
swarm.rotate_clockwise(90)
time.sleep(1)
swarm.land()