Getting Started

DroneKit-Python apps are typically run on Linux-based companion computers that travel on the vehicle and communicate with the autopilot via a serial port. However, during development it is usually easier to prototype apps on a standard Mac, Windows, or Linux computer using a simulated autopilot.

This topic explains how to set up and run DroneKit-Python (within MAVProxy) on the different host operating systems and then run a basic DroneKit app.

Setting up the vehicle/autopilot

For information on how to set up a vehicle (real and simulated) see:

Installing DroneKit

DroneKit can be installed on Linux, Windows and Mac OSX.

Installing DroneKit on Linux

If you are using Ubuntu or Debian Linux you can get most of the DroneKit dependencies by running:

sudo apt-get install python-pip python-dev python-numpy python-opencv python-serial python-pyparsing python-wxgtk2.8

The remaining dependencies (including MAVProxy), are installed when you get DroneKit-Python from the public PyPi repository:

sudo pip install droneapi


If you are planning to run DroneKit on a companion computer, make sure that the computer runs a variant of Linux that support Python and can install Python packages from the internet.

Installing DroneKit on Mac OSX

If you’re on Mac OSX, you can use Homebrew to install WXMac.

brew tap homebrew/science
brew install wxmac wxpython opencv

Uninstall python-dateutil (OSX and Windows come bundled with a version that is not supported for some dependencies):

sudo pip uninstall python-dateutil

Install DroneKit-Python and its remaining dependencies (including MAVProxy) from the public PyPi repository:

sudo pip install numpy pyparsing
sudo pip install droneapi

Installing DroneKit on Windows

The easiest way to set up DroneKit-Python on Windows is to use the Windows Installer. This is applied over the top of the MAVProxy Windows installation and includes all needed dependencies and the DroneKit-Python examples.


A new version of the Windows Installer is created with every patch revision. Don’t forget to update regularly for bug fixes and new features!

To install DroneKit-Python using the installer:

  1. Download and run the latest MAVProxy installer — accept all prompts.
  2. Download and run the latest DroneKit installer — accept all prompts (install in the same location as MAVProxy).

The installer packages DroneKit-Python as an application, which is launched by double-clicking an icon in the system GUI. After the MAVProxy prompt and console have started you can connect to the vehicle (instead of setting the connection when starting MAVProxy). You will still need to load DroneKit (not done by the installer - see #267). The examples are copied to C:\Program Files (x86)\MAVProxy\examples\.

It is also possible to set up DroneKit-Python on the command line (see Building DroneKit-Python on Windows).

Starting MAVProxy

Before executing DroneKit scripts you must first start MAVProxy and connect to your autopilot (simulated or real). The connection to the vehicle can be set up on the command line when starting MAVProxy or after MAVProxy is running.


If you’re using DroneKit-Python from the Windows installer there is no way to pass command line options to MAVProxy; you will have to start MAVProxy by double-clicking its icon and then connect to the target vehicle after MAVProxy has started.

Connecting at startup

The table below shows the command lines used to start MAVProxy for the respective connection types:

MAVProxy connection options
Connection type MAVProxy command
Linux computer connected to the vehicle via USB --master=/dev/ttyUSB0
Linux computer connected to the vehicle via Serial port (RaspberryPi example) --master=/dev/ttyAMA0 --baudrate 57600
SITL connected to the vehicle via UDP --master=
OSX computer connected to the vehicle via USB --master=/dev/cu.usbmodem1
Windows computer connected to the vehicle via USB --master=/dev/cu.usbmodem1

For other connection options see the MAVProxy documentation.

Connecting after startup

To connect to the autopilot once MAVProxy has already started use link add <connection> in the MAVProxy command prompt, where <connection> takes the same values as master in the table above. For example, to set up a connection to SITL running on the local computer at port 14550 do:

link add

If you’re connecting using a serial port you may need to first set up the baud rate first (the default is 57600). You can change the default baudrate used for new connections as shown:

set baudrate 57600    #Set the default baud rate for new connections (do before calling "link add")

See Link Management (MAVProxy documentation) for more information.

Loading DroneKit

DroneKit is implemented as a MAVProxy module (MAVProxy is installed automatically with DroneKit). The best way to load the DroneKit module into MAVProxy is to add it to the startup script (mavinit.scr).

Linux/MAC OSX:

echo "module load droneapi.module.api" >> ~/.mavinit.scr


echo module load droneapi.module.api >> %HOMEPATH%\AppData\Local\MAVProxy\mavinit.scr

Alternatively you can choose to manually (re)load DroneKit into MAVProxy every time you need it:

     MANUAL> module load droneapi.module.api
     DroneAPI loaded

Running an app/example

This section shows how to run the Vehicle State example, which reads and writes vehicle state and parameter information.


This example doesn’t take off, but it does arm the motors. Don’t run any example indoors on a real vehicle unless you have first removed its propellers.

The steps are:

  1. Get the DroneKit-Python example source code onto your local machine.

    The easiest way to do this is to clone the dronekit-python repository from Github. On the command prompt enter:

    git clone


    The Windows Installation copies the example code here: C:\Program Files (x86)\MAVProxy\examples\.

  2. Start MAVProxy and connect to the vehicle. For example:

    • To connect to a simulated vehicle when starting MAVProxy (from the command line): --master=
    • To connect to a simulated vehicle after starting MAVProxy (for example, on Windows):

      link add
  3. You should already have set up MAVProxy to load DroneKit automatically. If not, manually load the library using:

    module load droneapi.module.api
  4. Once the MAVProxy console is running, start by entering api start followed by the full file path of the script. For example:

    api start "C:\Program Files (x86)\MAVProxy\examples\vehicle_state\"

    The output should look something like that shown below

     MANUAL> api start "C:\Program Files (x86)\MAVProxy\examples\vehicle_state\"
     Get all vehicle attribute values:
      Location:  Attitude: Attitude:pitch=-0.00405988190323,yaw=-0.0973932668567,roll=-0.00393210304901
      Velocity: [0.06, -0.07, 0.0]
      GPS: GPSInfo:fix=3,num_sat=10
      groundspeed: 0.0
      airspeed: 0.0
      mount_status: [None, None, None]
      Mode: STABILIZE
      Armed: False
     Set Vehicle.mode=GUIDED (currently: STABILIZE)
      Waiting for mode change ...
     Got MAVLink msg: COMMAND_ACK {command : 11, result : 0}

For more information on running the examples (and other apps) see Running the Examples.