Inspiration

I always wanted to program drones but was intimidated with the cost of a readily programmable drone flight controller ($400 for a Pixhawk and GPS vs. $100 for a Naza-M Lite and GPS used in this project). While faced with this problem I realized that I could take advantage of a Raspberry Pi (that was already onboard my drone as part of another project) and an Arduino to command the drone’s orientation by providing PWM signals to the flight controller as if they were from a typical RC receiver.

What it does

FlyingPython provides a simple Python API to control the pitch and roll of a quadcopter drone, and a Raspberry Pi and Arduino to run the code and interface with the drone’s flight controller. Because manipulating the attitude is relatively low level, I also created a navigation algorithm that allows you to simply specify a target location and then watch as the drone flies to that location.

The FlyingPython API was written to be modular, meaning that it is possible to extend the API to interface with multiple drones. The navigation code was tested using a drone simulation called, ArduPilot SITL. Due to time constraints and technical issues I was not able to test the entire navigation stack on the actual drone hardware. However all components of the real drone hardware interface: GPS, magnetometer, and motor output have been tested on their own.

How I built it

  • Using ArduPilot SITL I created the navigation algorithm
  • Interfaced Arduino PWM outputs with flight controller
  • Interfaced Arduino with Naza-M Lite GPS
  • Wrote an Arduino program designed to communicate GPS data to the Raspberry Pi, and pitch and roll angles from the Raspberry Pi to the Arduino.
  • Wrote the Python program on the Raspberry side to communicate with the Arduino
  • Abstracted drone interface for SITL and actual hardware

Challenges I ran into

  • Wasn't able to reliably get the Arduino and Raspberry Pi to communicate, however it was reliable when connected to a PC.
  • It was difficult to test the GPS code in a concrete building because it was not possible to get a GPS fix.
  • Time constraints prevented me from testing the navigation code on the drone in flight

Accomplishments that I'm proud of

  • Implementing a navigation algorithm
  • Reading GPS data from the GPS that I already had on my drone
  • Writing an Arduino to PC communication program

What I learned

  • How to use abstract base classes in Python
  • How to build a PID controller

What's next for FlyingPython

  • There are a few things I have planned for FlyingPython:
  • Reduce the overshoot of the navigation algorithm
  • Solve the serial communication error between the Raspberry Pi and the Arduino
  • Test the navigation algorithm on the actual drone hardware
  • Create more example applications of FlyingPython

Built With

Share this project:
×

Updates