Build your own Autopilot - tutorial

I have written a tutorial on how to program your own AutoPilot/Flight Controller from scratch using an arduino/ArduPilot/RaspberryPi.  The tutorial will walk you through everything from reading the RC radio and controlling the motors through to how the PIDs are stacked on top of each other to get stable flight. Information on how to do this is quite hard to find on the Internet, so I hope this article will make the world of flight controllers more accessible and encourage more people to contribute to ArduCopter.

You can find the full article here:

and a video of the code from the article in action (you can download the code and try it on your APM - it'll behave like a KK board):

Note: the code actually flies better than the video demonstrates - my PID settings weren't optimally tuned!

Views: 23099

Comment by Hugues on July 31, 2013 at 3:56pm
This is one of, if not the best informative post explaining how an autopilot works inside. Great stuff. The clarity and simplicity of your explanations are a proof of your deep comprehension of this matter. Wow!
Comment by HeliStorm on July 31, 2013 at 9:35pm
Most of this is way over my head at the moment, but I will be interested to explore this more. I am a learn from doing type of person, and I have been interested in how these systems work. If nothing else, this can give me a better foundation of how everything works.
Comment by Gareth on August 1, 2013 at 7:27am


Not sure I really follow you - the purpose was to describe how the control algorithm works to stabilise a quad and how to code it.  The HAL library was really immaterial to the article.



Comment by Harry on August 1, 2013 at 9:54am

"AP_HAL_AVR_APM2 was not declared in this scope" 

I've got the library in the Arduino directory. 

Is there somewhere I need to #define or #include something or is it more complicated?

Comment by Gareth on August 1, 2013 at 10:00am

In your sketches folder, you need a directory called libraries that contains all the libs.



Comment by Harry on August 1, 2013 at 10:47am

Oh well, I dont whats wrong since that's where I put em.

Comment by Matt on August 1, 2013 at 2:56pm

This is great. I seen this when posted and started studying the article word for word. Very well written. I am def going to attempt something with these instructions. I wish my PI wasn't DOA. It was free so I can't complain. I may try getting the ODROID-U2 and use it in place of the PI. Again, thanks for your contribution to the community!

Comment by John Church on August 1, 2013 at 3:34pm
Watch out. I believe there's a misleading section of code in the Acro stab. example... ;-)

Really, really great intro though!
Comment by Gareth on August 1, 2013 at 3:42pm

How so? To my knowledge it is correct - and most of the code in the article was pasted from the working/correct completed code.

Comment by Marius van Rijnsoever on August 1, 2013 at 3:59pm

Awesome post thanks!


You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2015   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service