-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase watchdog timer and fix debug tool.
- Loading branch information
Showing
2 changed files
with
23 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |