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:

http://oweng.myweb.port.ac.uk/build-your-own-quadcopter-autopilot/

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: 6861

Tags: arduino, ardupilot, build, controller, diy, flight, pi, pids, raspberry


3D Robotics
Comment by Justin Cunningham on July 31, 2013 at 3:53pm

got my attention. my raspberry pi has nothing to do... hmm

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 thomas Butler on August 1, 2013 at 6:25am

Excellent work Gareth!  I see that the ArduCopter code v3x now has implemented a HAL (currently only APM and PX4 flight controllers have been abstracted).  I'd like to see someone make an abstraction for the Crius All-In-One board.  I would, but I just don't have the time...perhaps your effort would be more profitable if you concentrated on just the hardware and created an abstraction to support it.  I might be wrong here, but it seems as though you are hacking into too much of the code, or maybe the HAL in Arducopter 3x just isn't quite abstracted enough.  Check out the MegapirateNG code.  This is a deriviative of Arducopter 2.7(??) code.  The megapirateNG code fork seems to be at a standstill since January. There is a HAL layer with numerous boards that have been abstracted; including the APM. 

Comment by Gareth on August 1, 2013 at 7:27am

Thomas

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.

Best

Gareth

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.

Best

Gareth

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!


Moderator
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

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

Join DIY Drones

© 2014   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service