Skip to content

JhaAman/hackflight

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Hackflight is simple C++ firmware for inexpensive quadcopter 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 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 only on STM32F103 flight-controller boards (Naze32 and clones like Flip32, MultiRC, etc.) The original Hackflight idea was to write firmware for flight controllers built from the Arduino / Teensy hardware. As you'll 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. But with all the features you can now get onboard an inexpensive STM32F103 board (barometer, magnetometer, flash RAM), there seems little point in building your own board, unless you're interested in hardware hacking. So Hackflight currently supports only the STM32F103 boards, while keeping the Arduino design principles. The code provides abstraction (through the Board class) that should make it easy to use on other boards.

Meanwhile, to try Hackflight on your board, you'll need to be running Linux on your desktop/laptop computer, with the GNU ARM toolchain installed, and you'll need to grab the BreezySTM32 repository.

In hackflight/boards/naze/130mm there's code that uses PID values (pidvals.hpp) appropriate that worked well on my 130mm quadcopter. Likewise, hackflight/boards/naze/250mm contains code that uses values that worked on a 250mm quad. So choose whichever is closest to your vehicle, cd to that folder, and edit the Makeke to reflect where you put BreezySTM32. Then type make, which will build the firmware binary in the obj directory. If you've already got Baseflight or Cleanflight running on your board, you should then just be able to type make flash to flash Hackflight onto it. If you run into trouble, you can short the bootloader pins and type make unbrick.

Hackflight flies your quadcopter in Level (a.k.a. Stable) mode. So 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 gyro by putting the collective (left) stick in full upper-left and the cyclic (right) in full center-down position. You can calibrate the accelerometer with collective lower-left and cyclic center-down. 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

No packages published

Languages

  • Python 50.6%
  • C++ 43.4%
  • Makefile 4.0%
  • Other 2.0%