Swarm
Swarm library for controlling multiple Tellos simultaneously
Source code in djitellopy/swarm.py
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 151 152 153 154 155 156 157 158 159 |
|
__getattr__(attr)
Call a standard tello function in parallel on all tellos.
swarm.command()
swarm.takeoff()
swarm.move_up(50)
Source code in djitellopy/swarm.py
128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
__init__(tellos)
Initialize a TelloSwarm instance
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tellos |
List[Tello]
|
list of [Tello][tello] instances |
required |
Source code in djitellopy/swarm.py
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 |
|
__iter__()
Iterate over all drones in the swarm.
for tello in swarm:
print(tello.get_battery())
Source code in djitellopy/swarm.py
142 143 144 145 146 147 148 149 150 |
|
__len__()
Return the amount of tellos in the swarm
print("Tello count: {}".format(len(swarm)))
Source code in djitellopy/swarm.py
152 153 154 155 156 157 158 159 |
|
fromFile(path)
staticmethod
Create TelloSwarm from file. The file should contain one IP address per line.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
path to the file |
required |
Source code in djitellopy/swarm.py
23 24 25 26 27 28 29 30 31 32 33 |
|
fromIps(ips)
staticmethod
Create TelloSwarm from a list of IP addresses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ips |
list
|
list of IP Addresses |
required |
Source code in djitellopy/swarm.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
parallel(func)
Call func
for each tello in parallel. The function retrieves
two arguments: The index i
of the current drone and tello
the
current [Tello][tello] instance.
You can use swarm.sync()
for syncing between threads.
swarm.parallel(lambda i, tello: tello.move_up(50 + i * 10))
Source code in djitellopy/swarm.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
sequential(func)
Call func
for each tello sequentially. The function retrieves
two arguments: The index i
of the current drone and tello
the
current [Tello][tello] instance.
swarm.parallel(lambda i, tello: tello.land())
Source code in djitellopy/swarm.py
78 79 80 81 82 83 84 85 86 87 88 89 |
|
sync(timeout=None)
Sync parallel tello threads. The code continues when all threads
have called swarm.sync
.
def doStuff(i, tello):
tello.move_up(50 + i * 10)
swarm.sync()
if i == 2:
tello.flip_back()
# make all other drones wait for one to complete its flip
swarm.sync()
swarm.parallel(doStuff)
Source code in djitellopy/swarm.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|