Solo Development Guide

DroneKit

DroneKit-Python is a Python library that can be used to connect to, monitor and control a vehicle. You can use it to write your own scripts and interact with Solo from either a ground station or from Solo's onboard companion computer.

Working with DroneKit-Python is virtually the same on any platform/vehicle. Developers should read the DroneKit-Python Documentation in order to understand the key concepts.

This topic provides a very brief introduction to the "nuances" of working with DroneKit-Python on Solo. It explains how a script should connect to Solo, how to deploy and run scripts on the device, some limitations of using DroneKit scripts (as opposed to using Smart Shots), and how to access useful platform features.

Connecting to Solo

The MAVLink telemetry protocol (used to communicate with Solo) is served on UDP port 14550. Scripts can connect as a UDP client to udpin:0.0.0.0:14550 from any external device connected to its network or from Solo's terminal.

From Python, you connect to Solo on this port using the connect() method as shown:

from dronekit import connect

# Connect to UDP endpoint (and wait for default attributes to accumulate)
print 'Connecting to Solo ...'
vehicle = connect('udpin:0.0.0.0:14550', wait_ready=True)

The connect() method returns a Vehicle object that can be used to observe and control the drone.

Other than the connection string used for Solo, all other aspects of calling the API are the same as in the DroneKit-Python documentation.

Deploying scripts to Solo

Scripts can be deployed and run on Solo using the Solo CLI. The CLI takes care of packaging all the scripts in a folder along with all dependencies listed in the folder's requirements.txt file. It can then be used to transfer the package to Solo, install it, and run a specified script in a virtual environment.

solo script pack

solo script is used to package all code and dependencies needed to run a script. It creates an archive that can be deployed to Solo (as described in the next section).

The command is run inside a directory which should contain all needed Python scripts along with a requirements.txt file listing all the needed pip dependencies. Minimally this will include the latest version of DroneKit:

   dronekit>=2.0.0

Open a terminal, navigate to the directory to package, and enter the following command:

solo script pack

After some processing, this will create an archive called solo-script.tar.gz in your current directory, or display an error if the process could not complete.

solo script run ...

In order to deploy the script archive and run the app, first connect to Solo's wifi network.

Then enter the following command to upload the script archive to Solo, unpack it and its dependencies, and then attempt to run the specified python script (yourscriptname.py):

solo script run yourscriptname.py

Accessing Solo Features

DroneKit-Python scripts can use any features of the underlying platform that are (or can be made) accessible to Python.

For example, DroneKit-Python does not have any API for direct access to camera/video (though it can control the Camera gimbal). However it can use platform services to access video frames and libraries like OpenCv for post-processing. See this example for more information.

DroneKit-Python Limitations

There is currently no inbuilt support for:

  • Launching DroneKit-Python scripts from the Controller.
  • Launching DroneKit-Python scripts on system boot.
  • Passing parameters to a script after it has started.
  • Pausing or restarting a script due to external interaction.

Some of these features are available to Smart Shots.