Tuesday, June 26, 2018

Dronekit-Python

Installation Tutorial


http://python.dronekit.io/develop/installation.html


Purpose

Dronekit-Python is a library of Python code that allows you to send commands to the simulated quadcopter using a Python Script (as opposed to Ardupilot's clunkier command line interface).  This will allow you to write your own Python code to manipulate the behavior of the quad how you see fit. 

For example, I use 3 different scripts depending on the situation: one to allow the user to have manual control over the quad, one to allow the quad to follow a mission in AUTO mode, and one similar to the second, but uses GUIDED mode so that it can change its mission at any time throughout the simulation (but this last one is a topic for another post).

Things to Note


*Be sure to use the examples that come with the Dronekit-Python repository.  These can be modified to fit your needs and can you teach you how to do things like takeoff or navigate to a new position.

*Dronekit-Python's connect function has a default timeout of 30 seconds.  If it cannot find the UDP port corresponding to an available quadcopter (either real or simulated), it will close the program.  If your SITL program has to initialize many parameters, then you might have to consider adding sleep statements or delays to ensure that SITL has enough time to get started before launching Dronekit-Python.

*AUTO mode does not allow anything to dynamically alter the mission stored in the quadcopter.  The quad must first land and disarm its motors before saving a new mission into the quadcopter.  From there, it can take off, and enter AUTO mode again.  This is the advantage of "GUIDED" mode over "AUTO": you can take control of the quad at any point and tell it to do something different.

*The weakness to "GUIDED" mode is that it takes constant input and cannot simply take in a mission file and complete it autonomously like in "AUTO" mode.  In our project, we want to be able to have the quadcopter complete a mission automatically, but also be able to change its mission if the BRECCIA server prompts it to, even while it is in the air.  That is why I designed a dynamic planner in Python.  This planner can receive new missions from our BRECCIA server (which uses Java), and then parse these mission files, sending them to the quadcopter one after the other while it is in "GUIDED" mode.

*Dronekit-Python can only affect the quadcopter's state.  It cannot change the environment (things like wind speed or direction).

No comments:

Post a Comment