This is an autopilot for a quadcopter drone I wrote from scratch back in 2012. I used the physics engine in Unity3d to validate my ideas and develop the control logic, then I used the same autopilot code in a physical set up.
At the time, I was very new to electronics and I chose an embedded platform that required the code to run on a host computer. Thus, a sensor reading had to travel from the IMU on the quadcopter to the host computer (via USB) and then the control signal had to travel back again to the motor controllers. Unfortunately, this introduced a considerable delay in the control loop which made the quadcopter oscillate once airborne. However, the quadcopter actually flew a couple of times so I call the endeavour a success!