Skip to content

foorenxiang/hackflight

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2,002 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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), and currently works on STM32F103 flight-controller boards (Naze32 and clones like Flip32, MultiRC, etc.), the Alienflight F3 board, and the Arduino-compatible Teensy 3.1/3.2 microcontroller (with additional hardware). Thanks to a major effort by Sytelus, the core Hackflight firmware now adheres to best practices for C++. As you can see, the code follows the Arduino design pattern of a startup 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 only parameters you should need to adjust are the PID tuning params. As with Baseflight, you get a gyro auto-calibration sequence on startup, indicated by steady green LED that turns off when the calibration is done. You can re-calibrate the accelerometer and gyroscope by putting the collective (left) stick in full lower-left and the cyclic (right) in full center-down position. 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 (main.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

 
 
 

Contributors

Languages

  • C++ 32.4%
  • Java 32.0%
  • Python 28.9%
  • Makefile 5.5%
  • Other 0.8%
  • C 0.4%