How to program a drone using Python
If you’re using the sticks of a remote controller to tell your drone where to go, is it really autonomous? And isn’t autonomous the real definition of a drone? To actually control your drone in its true form – that is, enabling it to fly autonomously without you telling it where to go in real-time — then you’ll have to pre-program its flight. And while that’s easier said than done, it’s not actually that hard to program a drone using Python.
DIY drone-making whiz Caleb Berquist is an engineer by day, but he has an awesome side hustle that can help everyone out. He created Drone Dojo, a site that features how-to, online drone classes ranging from free instructional videos, lengthy text guides and full, multi-hour long virtual courses.
And yes, Berquist put out this great, free guide to “How to Control a Drone with Python.” Berquist is the expert so I’ll let you click that link and read his guide, but I won’t completely leave you hanging. Before you leave for Berquist’s excellent guide, here are some basics you’ll need to know:
Plus: scroll down to learn how to get a Drone Girl exclusive discount on the Drone Dojo Python course!
What you need to program a drone using Python
A computer (and in turn, a drone) needs hardware, firmware (code that commands the hardware) and software to function. If you’re programming a drone, we’ll assuming you already have the hardware ready to go (those are the propellers, motors, batteries, etc). That said, you don’t necessarily need hardware on hand if you simply want to learn how to program a drone using Python — but don’t need to put the results to the test IRL. Simply use a simulated MAVLink quadcopter to test it virtually. Or, if you do want to put it to the test IRL, you can also build your own drone (and hey, check out Berquist’s guide to how to build a Raspberry Pi drone, which can help you make that happen).
No matter what you choose, you will need the firmware and software. Here’s what you need to know:
Firmware: Ardupilot
Ardupilot is one of the best ways to command a drone’s hardware. It’s capable of sending approximately 400 commands per second to the drone’s motors.
ArduPilot is very widely supported by many of the most popular flight control boards including Pixhawk and Cube-based drones.
Software: Dronekit python
Berquist recommends you use Dronekit python, an open-source python library that provides high level functions such as commanding drone movement or checking vehicle status. Learn more about that here:
And together Dronekit Python and ArduPilot can communicate using what’s called MAVLink (which Berquist alludes to in the video above). That’s what you’ll need to write your first Dronekit Python Script, so you can command your drone to do everything you want — takeoff, land and everything in between.
All of those videos are free snippets from Drone Dojo’s longer online course on drone programming with Python. It costs $197, but goes much deeper into what you can learn from a couple videos (this course is 3.5 hours long).
The course is designed for everyone from an entrepreneur working up an epic drone delivery project, to a student looking to learn about engineering in a fun, applicable way (you will need a basic coding background – think basic linux command line and python knowledge).
You can register for Drone Dojo’s self-paced online drone programming with Python course here.
Here’s a limited-time offer! The first 30 readers who use promo code DRONEGIRL2 at checkout will get 10% any Drone Dojo course, including this one!
Is it possible to find out if this drone is compatible with dronekit or mavlink. Or, is it possible to program this drone somehow in python. any info is appreciated. https://www.banggood.com/LS-MIN-Mini-WiFi-FPV-with-4K-or-1080P-HD-Camera-Altitude-Hold-Mode-Foldable-RC-Drone-Quadcopter-RTF-p-1669764.html
can you upload a video for making ufo please i have plan to make so can you upload
Thanks for sharing this informative article. I appreciate that the attempt to cover all the fundamentals of drone. This blog is more helpful. I got more information about drone software development programing.
Hi you have created a wonderful learning environment! * Question: I decided to to learn Python programming and I wish there were a “Python Drone Virtual environment” to be able to add more sensors and situations to have full creativity freedom that could be implemented in hardware latter. Long time ago there used to be a sophisticated robot programming environment with very basics graphics called “PYRO”.
Check out SITL section of Ardupilot documentation