Skip to content

Commit

Permalink
Increase watchdog timer and fix debug tool.
Browse files Browse the repository at this point in the history
  • Loading branch information
thavel committed Jun 18, 2016
1 parent f29ed01 commit bf3c688
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion aioparrot/ardrone/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Port(IntEnum):

class _Protocol(object):

WATCHDOG = 1.0
WATCHDOG = 0.2

def __init__(self, loop, opt):
self.loop = loop
Expand Down
26 changes: 22 additions & 4 deletions debug.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
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.left(2)
await client.right(2)
await client.forward(2)
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=loop)
asyncio.ensure_future(main())
loop.add_signal_handler(SIGINT, stop)
loop.run_forever()
log.info("Exit")

0 comments on commit bf3c688

Please sign in to comment.