-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.py
46 lines (37 loc) · 1.02 KB
/
debug.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
import asyncio
import logging
from signal import SIGINT
from aioparrot import Device, drone
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)
client = None
def stop():
asyncio.ensure_future(cancel(abort=True))
async def cancel(abort=False):
global client
if abort and client:
log.info("Aborting the mission")
await client.land()
await client.stop()
loop = asyncio.get_event_loop()
loop.call_soon_threadsafe(loop.stop)
async def main():
global client
client = drone(Device.ARDRONE2)
client.ceiling = 10
client.speed = 0.2
log.info("Launching the drone")
await client.start()
await client.takeoff()
await client.forward(1)
await client.backward(1)
await client.land()
await client.stop()
log.info("Mission completed")
await cancel()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
asyncio.ensure_future(main())
loop.add_signal_handler(SIGINT, stop)
loop.run_forever()
log.info("Exit")