Skip to content

Simple quadcopter flight control firmware and simulator for C++ hackers

License

Notifications You must be signed in to change notification settings

YuhangWUST/hackflight

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hackflight: Simple quadcopter flight control firmware and simulation for C++ hackers

Hackflight is simple header-only C++ firmware for quadcopter flight controllers and simulators. 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 Cleanflight (great for getting started when you're on a budget) 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.

Hackflight derives from the Baseflight firmware (which in turn derives from Multiwii). Although there is legacy support for STM32F103 flight-controller boards (Naze32 and clones like Flip32, MultiRC, etc.) and the Alienflight F3 board, the hardware focus of the project has shifted to the Arduino-compatible boards designed by Pesky Products: the Teensy Flight Controller and the STM32L4-based Ladybug FC.

Thanks to a major effort by Sytelus, the core Hackflight firmware now adheres to standard practices for C++. As you can see, the code follows the Arduino design pattern of a setup() routine that calls the init() method of a few objects (IMU, RC, PID, Board) and a loop() routine that calls the update() method and other methods of those objects. The code provides abstraction (through the Board class) that should make it easy to use on other boards. The Board class declares the pure virtual methods that you must override for implementation on a particular board or simulator, as well as a few “extras”, virtual methods that you can override for additional functionality like altitude-hold, hover-in-place, etc. Support for these extra methods can be found in the include/extras folder; for example, there is a Baro class that performs typical functions of a barometer.

The only parameters you should need to adjust are the PID tuning params. As usual, collective lower-right arms the board, and lower-left disarms it, as indicated by the red LED. The green LED will flash when the board is tilted by more than 25 degrees.

Although Hackflight was designed to be “headless” (no configurator program), it is useful to get some visual feedback on things like vehicle orientation and RC receiver PWM values. So in the gcs folder you'll find a Python program (hackflight.py) that allows you to connect to the board and see what's going on. To use this program you'll need to install MSPPG, a parser generator for the Multiwii Serial Protocol (MSP) messages used by the firmware. Follow the directions in that repository to install MSPPG for Python.

If you find Hackflight useful, please consider donating to the Baseflight or Cleanflight projects from which it is derived.

About

Simple quadcopter flight control firmware and simulator for C++ hackers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 36.2%
  • Java 30.3%
  • Python 27.4%
  • Makefile 4.9%
  • Other 0.8%
  • C 0.4%