This is a proof-of-concept attempt working towards building a Linux-based quadcopter flight control system.
Many flight control systems are currently written on either bare metal or using an RTOS. These techniques are often less approachable to developers, as they tend to require somewhat complicated toolchains and either sophisticated simulators or hardware-in-the-loop development. Furthermore, this was often necessitated by relatively slow computation--the timing requirements on control loops meant that even a few years ago, it may have been difficult to run a non-deterministic control loop on a single-threaded board and be relatively certain that it would run quickly and reliably enough without the main thread hanging at any point. The past few years have seen many more low-cost, multi-threaded high performance ARM single-board computers running Linux become available, which may offer a way to build a flight-control system using only the board's standard I/O and a few peripherals, such that the native performance of the board is high enough maintain stable flight using an off-the-shelf Linux SBC.
Notably, this idea was heavily explored by Anders Martenssson at the Blekinge Institute of Technology in their senior thesis paper, which seemed to indicate this approach could be relatively promising.
This is the hardware I'm currently using. Most of these components could feasibly be switched out with something else if necessary (which is sort of the point), but in general you can assume that these will work together.
Hardkernel Odroid-C4 4GB, running the most recent operating system and ideally with an eMMC module
/media/boot/config.ini
file to include overlays = pwm_ab pwm_cd pwm_ef
. More details can be found on a Hardkernel forum post hereBosch BNO055 Absolute Orientation Sensor
BMP280 Altitude/Pressure Sensor
2018
edition and should work out-of-the-box with an Odroid-C4Blue Robotics BasicESC
Brushless ESCs
Frame
Plus things like screw terminals, plastic rotors, a WiFi adapter for the Odroid-C4. As mentioned, for the motor power, I'm using a 3S/30C LiPo battery using XT-60 connectors, which is actually pretty important--I'm registering somewhere between 1.5-2.0A per motor to get flight at the moment, which was more than my 5A benchtop power supply could produce, so I had switch over to a LiPo battery for development.
Subsets of this code, with the described hardware have been proven to work on one and two-axis stabilization controls problems. In other words, a single motor/propeller on an unsupported lever arm can indefinitely maintain a level position with low oscillation. The same goes for an in-line pair of lift-producing motor on opposite sides of a pivot point.
I've also done some work with all four motors running, and holding a quadcopter chassis from the corner (I haven't finished the counter-rotation yet for the motors I've been using, so I can't let go entirely) the quadcopter is able to stay relatively level in plane with little input from my arm. When I kill the control signal, the chassis drops, so I believe it's safe to say that the attitude control system is at least close to working.
This code is licensed under GPLv3