Running the Examples

General instructions for running the example source code are given below. More explicit instructions are provided within the documentation for each example (and within the examples themselves by passing the -h (help) command line argument).

Tip

The examples all launch the dronekit-sitl simulator and connect to it by default. The --connect argument is used to instead specify the connection string for a target vehicle or an externally managed SITL instance.

To run the examples:

  1. Install DroneKit-Python if you have not already done so! Install dronekit-sitl if you want to test against simulated vehicles.

  2. 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 http://github.com/dronekit/dronekit-python.git
    
  3. Navigate to the example you wish to run (or specify the full path in the next step). The examples are all stored in subdirectories of dronekit-python/examples/.

    For example, to run the vehicle_state example, you would navigate as shown:

    cd dronekit-python/examples/vehicle_state/
    
  4. Start the example as shown:

    • To connect to a simulator started/managed by the script:

      python vehicle_state.py
      
    • To connect to a specific vehicle, pass its connection string via the connect argument. For example, to run the example on Solo you would use the following command:

      python vehicle_state.py --connect udpin:0.0.0.0:14550
      

Warning

Propellers should be removed before testing examples indoors (on real vehicles).