How to use the DroneKit SITL simulator
The SITL (Software In The Loop) simulator allows you to create and test DroneKit-Python apps without hardware. SITL can run natively on Linux (x86 architecture only), Mac and Windows, or within a virtual machine. The sections below explain how to install and run SITL, and how to connect to DroneKit-Python and Ground Stations at the same time. For more information, see the DroneKit wiki on how to set up a simulated vehicle.
The tool is installed (or updated) on all platforms using the command:
pip install dronekit-sitl -UI
Before running any scripts (on the simulator or not), activate the virtualenv. This has all the dependencies needed for this project. Do this by navigating to the sparrow-dev/
directory on the dev branch, and running:
source env/bin/activate
DroneKit-SITL exposes a Python API for managing a SITL instance, which you can use to start and control simulation from within your scripts.
from dronekit_sitl import SITL
sitl = SITL()
sitl.download('solo', '1.2.0', verbose=True) # system (e.g. "copter", "solo"), version (e.g. "3.3"), verbose
sitl_args = ['-I0', '--model', 'quad', '--home=-35.363261,149.165230,584,353']
sitl.launch(sitl_args, verbose=False, await_ready=False, restart=True)
DroneKit-SITL waits for TCP connections on 127.0.0.1:5760. DroneKit-Python scripts running on the same computer can connect to the simulation using the connection string as shown:
vehicle = connect('tcp:127.0.0.1:5760', wait_ready=True)
Now you can do anything on the simulator that you could do on the drone! See the DroneKit-Python API Reference for the full list of commands.