Skip to content

Instantly share code, notes, and snippets.

@deliastephens
Created July 15, 2019 21:21
Show Gist options
  • Save deliastephens/2fd69b1a390231018f604adf111d9def to your computer and use it in GitHub Desktop.
Save deliastephens/2fd69b1a390231018f604adf111d9def to your computer and use it in GitHub Desktop.
SITL Testing Environment

Robust Testing and Debugging with SITL

Desired Features

  • Simple UI
  • Run multiple different missions with home point at the starting location.
  • Change conditions
  • Inject failures
  • Interface with MissionPlanner, etc.
  • [ ]

Quick Code

Run SITL: sim_vehicle.py --console --out 192.168.5.32:14550 -L MEX -v ArduPilot
Run Fault Injector (in folder): python FaultInjector.py

DroneKit and Python

I quickly realized the best way to write testing scripts would not be with bash scripts or anything archaic and Windows-y, but with Python instead. My ultimate goal would quickly become a Python simulation UI - one where it is easy to load missions, add complicating factors, etc.

I found a UAV Fault Injector project which seemed like a great place to start. I ended up deciding to modify this script with an ability to load and run custom missions via DroneKit to build a fully-featured, all-in-one platform.

Installing DroneKit

My first tragedy arrived when I realized the entire python-dronekit website was down. Luckily, some fans had created another host, so I was in business.

Basic Modifications and Compatibility

My first order of business was to modify this Python script to get it to work with my particular Python setup. This involved changing capitalization, package names, spaces, tabs, etc. Then I had to connect this package to my flight controller, which also ended up not being too difficult.

Modifications
Changelogs below, and available on my GitHub commit history:

  • Spelling mistakes
  • Renamed packages
  • Changed FS_BATT_MAH to BATT_CRT_MAH to reflect ArduPilot development.
  • Added ability to load custom Waypoint files.

Modifying Missions

The thing that I first noticed was the absolute lat/long coordinates for missions. I thought it would be quite helpful to write a Python script that would generate new Waypoint files based on the drone’s current home position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment