-
Notifications
You must be signed in to change notification settings - Fork 0
/
scheduler.py
34 lines (25 loc) · 883 Bytes
/
scheduler.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
import asyncio
from audioop import max
from time import time
from macarena_moves import MACARENA
from tello import tello
from moves import flip, FlipDirection, forward, back, left, right, wait, takeoff, land, beats2ms, Milliseconds
async def scheduler(moves):
print("START")
await takeoff()
await asyncio.sleep(1)
for next_move, beats_budget in moves:
started = time()
await next_move(beats_budget)
ended = time()
remaining_time_for_move = started + beats2ms(beats_budget) / 1000 - ended
if remaining_time_for_move < 0:
print("WARNING: Move taken too long. Remaining time: ", remaining_time_for_move)
else:
await asyncio.sleep(remaining_time_for_move)
print("END")
await wait(500)
await land()
tello.end()
if __name__ == '__main__':
asyncio.run(scheduler(MACARENA))