Skip to content

simondlevy/Hackflight

Repository files navigation

Intro

Hackflight is a C++ software toolkit for building multirotor flight controllers. It is geared toward people like me who want to tinker with flight-control firmware, and use it to teach students about ideas like inertial measurement and PID tuning. If you are in the 99% percent of users who just want to get your vehicle flying without getting into firmware hacking, I recommend Betaflight (great for getting started when you're on a budget, and the origin of much of the code in Hackflight) or the Ardupilot system (for sophisticated mission planning with waypoint navigation and the like). In addition to big user communities and loads of great features, these platforms have safety mechanisms that Hackflight lacks, which will help avoid injury to you and damage to your vehicle.

Use cases

Hackflight has been tested on the following platforms:

To make it easy to develop flight firmware using Arduino-compatible microcontrollers, Hackflight is laid out as an Arduino library and uses the Arduino API; however, the core flight-control algorithm is hardware-independent.

Design principles

Hackflight attempts to maintain a simple relationship between the code and the elements of the flight-control dataflow diagram shown below. Boxes represent data, ovals represent functions, and feedback arrows represent the need for functions that have state (instance variables); for example, the maintenance of an error integral in a PID controller:

By using header-only C++ classes whenever possible, avoiding C-style macros and null pointers, and leveraging existing Arduino libraries for receivers, ESCs, and IMUs, Hackflight supports a composable approach to taming the complexity of flight control: you instantiate a Board subclass, passing it your IMU settings, PID controllers, mixer, ESC type, and LED pin number. In your loop function, you just call the step() method on the Board object, passing it the raw values from your IMU. Look at this example program to get an idea of how this approach works.

Desktop visualizer app

Because it is useful to get some visual feedback on things like vehicle orientation and RC receiver channel values, we also provide HFViz, a very simple visualizer program that allows you to connect to the board and see what's going on. Check out the HFViz README for more information.

Citing Hackflight

Please cite Hackflight as:

@ARTICLE{10.3389/fnbot.2020.00016,
AUTHOR={Levy, Simon D.},   
TITLE={Robustness Through Simplicity: A Minimalist Gateway to Neurorobotic Flight},      
JOURNAL={Frontiers in Neurorobotics},      
VOLUME={14},           
YEAR={2020},      
URL={https://www.frontiersin.org/articles/10.3389/fnbot.2020.00016},       
DOI={10.3389/fnbot.2020.00016},      
ISSN={1662-5218}
}

About

C++ flight-control toolkit for makers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published