<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Andrei Korigodski</title>
    <description>The latest articles on DEV Community by Andrei Korigodski (@korigod).</description>
    <link>https://dev.to/korigod</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F481497%2Fda92e5db-0026-4604-bedc-b60d5f8ca9a2.png</url>
      <title>DEV Community: Andrei Korigodski</title>
      <link>https://dev.to/korigod</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/korigod"/>
    <language>en</language>
    <item>
      <title>Open source framework to start programming drones within an hour</title>
      <dc:creator>Andrei Korigodski</dc:creator>
      <pubDate>Wed, 28 Oct 2020 12:27:37 +0000</pubDate>
      <link>https://dev.to/korigod/open-source-framework-to-start-programming-drones-within-an-hour-4b0l</link>
      <guid>https://dev.to/korigod/open-source-framework-to-start-programming-drones-within-an-hour-4b0l</guid>
      <description>&lt;p&gt;Programming is utterly cool and so are drones, so it's hard to imagine more exciting activity than making drones to fulfill our wishes using the plain ol' Python code.&lt;/p&gt;

&lt;p&gt;But here's the thing: quadcopters, these nimble bastards, are never willing to do what they're told. It's a lot more fun for them either to refuse to fly, or to fly like hell, crashing into the first chandelier they can find (and they're pretty good at it, trust me). To circumvent this &lt;em&gt;highly&lt;/em&gt; unfortunate trait we've created an open source framework, called &lt;a href="https://clover.coex.tech/en/" rel="noopener noreferrer"&gt;clover&lt;/a&gt;, or just &lt;a href="https://clover.coex.tech/en/" rel="noopener noreferrer"&gt;🍀&lt;/a&gt;, which does all the heavy lifting on a quadcopter to allow you to take off with a single line of code. It executes on the onboard Raspberry Pi computer, using its camera for the computer vision navigation.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/CopterExpress" rel="noopener noreferrer"&gt;
        CopterExpress
      &lt;/a&gt; / &lt;a href="https://github.com/CopterExpress/clover" rel="noopener noreferrer"&gt;
        clover
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      ROS-based framework and RPi image to control PX4-powered drones 🍀
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;clover🍀: create autonomous drones easily&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/CopterExpress/cloverdocs/assets/clover42-main-margin.png"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FCopterExpress%2Fcloverdocs%2Fassets%2Fclover42-main-margin.png" width="400px" alt="COEX Clover Drone"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Clover is an open source &lt;a href="https://www.ros.org" rel="nofollow noopener noreferrer"&gt;ROS&lt;/a&gt;-based framework, providing user-friendly tools to control &lt;a href="https://px4.io" rel="nofollow noopener noreferrer"&gt;PX4&lt;/a&gt;-powered drones. Clover is available as a ROS package, but is shipped mainly as a preconfigured image for Raspberry Pi. Once you've installed Raspberry Pi on your drone and flashed the image to its microSD card, taking the drone up in the air is a matter of minutes.&lt;/p&gt;
&lt;p&gt;COEX Clover Drone is an educational programmable drone kit, suited perfectly for running clover software. The kit is shipped unassembled and includes Pixracer-compatible autopilot running PX4 firmware, Raspberry Pi 4 as a companion computer, a camera for computer vision navigation as well as additional sensors and peripheral devices. Batteries included.&lt;/p&gt;
&lt;p&gt;The main documentation is available at &lt;a href="https://clover.coex.tech/" rel="nofollow noopener noreferrer"&gt;https://clover.coex.tech&lt;/a&gt;. Official website: &lt;a href="https://coex.tech/clover" rel="nofollow noopener noreferrer"&gt;coex.tech/clover&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.kickstarter.com/projects/copterexpress/cloverdrone" rel="nofollow noopener noreferrer"&gt;&lt;strong&gt;Support us on Kickstarter!&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Video compilation&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="https://youtu.be/u3omgsYC4Fk" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/290cc3b73555ce1f9e3b85b3fbe0bfa8d774ab2a77505ee96ac57d56bf39ec6d/687474703a2f2f696d672e796f75747562652e636f6d2f76692f75336f6d6773594334466b2f687164656661756c742e6a7067" alt="Clover Drone Kit autonomy compilation"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Clover drone is used on a wide range of educational events, including &lt;a href="https://www.youtube.com/watch?v=xgXheg3TTs4" rel="nofollow noopener noreferrer"&gt;Copter Hack&lt;/a&gt;…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/CopterExpress/clover" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Thousands of developers and students use &lt;a href="https://github.com/CopterExpress/clover" rel="noopener noreferrer"&gt;🍀&lt;/a&gt; to code a drone — and I'll tell you, why you should join them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why should I, really?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Many of you have quadcopters, but is it really cool to pilot them with a remote control? Especially when there's a way to make the drone bring you beer, chase your friends, perform aerobatics... completely on its own! Here are some examples of what an autonomous drone can do: &lt;iframe width="710" height="399" src="https://www.youtube.com/embed/cx_WKjXqCjU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Drones are the most involving and interesting way to learn programming. Whether you are learning, teaching your child or work in an educational institution, drones are great tool to teach Python, C++, computer vision and Linux. You don't need gamification or other tricks to make the education appealing anymore. Drones are being used in universities as well — computer vision, machine learning and swarms are trending academic topics.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The drone programming skills are an extremely valuable nowadays. Not only a lot of companies start their drone deliveries, but drones also use the same technologies as self-driving cars, so you can apply your skills to create other autonomous vehicles, or robots of any kind.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you like participating in open source projects, drones are amazing opportunity to have fun and contribute at the same time! Robotics projects usually don't have an abundance of contributors, so every contribution is highly appreciated.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Isn't it too hard?
&lt;/h3&gt;

&lt;p&gt;Autonomous vehicles, as any advanced robots, are incredibly hard to do from scratch because of complexity of the hardware and its interactions with the environment. We created &lt;a href="https://clover.coex.tech/en/programming.html" rel="noopener noreferrer"&gt;clover🍀 framework&lt;/a&gt; to reduce the barrier of entry as much as possible — all you need to do is to assemble the drone and flash our preconfigured image on the Raspberry Pi's microSD card. Then you can connect to your drone with Wi-Fi and use either SSH or web interface to make it fly. Thanks to &lt;a href="https://en.wikipedia.org/wiki/Robot_Operating_System" rel="noopener noreferrer"&gt;ROS&lt;/a&gt;, popular open source robotic middleware, you can use almost any programming language to interact with the drone's API. For example, that's how to take off using the Python API:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="c1"&gt;# Take off and hover at 1 m above current position
&lt;/span&gt;&lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frame_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;auto_arm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft0hyabm491tikwbgovbd.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ft0hyabm491tikwbgovbd.gif" alt="Takeoff 320x320 br0.28 c1.6 15 fps"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pretty simple, huh? Let's try to do something a bit more complex. Wanna a drone to fly by a rectangle trajectory in the endless loop? Here we go:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="nf"&gt;while&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frame_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rospy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frame_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rospy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frame_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rospy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="o"&gt;=-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frame_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;body&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rospy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frzpb9soao087dsuz7kr5.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frzpb9soao087dsuz7kr5.gif" alt="Square flight using flow (1x, br0.28, c1.6, cropped, 560x270)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
  What does these arguments mean?
  &lt;br&gt;
&lt;code&gt;x&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;z&lt;/code&gt; indicate the coordinates to which to fly, and &lt;code&gt;frame_id&lt;/code&gt; determines what these coordinates are relative to: they can be relative to the drone's current position, or to some recognized object, or to the room, or even to Earth, if we use GPS. &lt;code&gt;speed&lt;/code&gt; is pretty self-explanatory.&lt;br&gt;


&lt;/p&gt;

&lt;p&gt;If even that is not simple enough, you can use &lt;a href="https://clover.coex.tech/en/blocks.html" rel="noopener noreferrer"&gt;the visual web interface&lt;/a&gt; based on &lt;a href="https://github.com/google/blockly" rel="noopener noreferrer"&gt;Google Blockly&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fclover.coex.tech%2Fassets%2Fblocks%2Fblocks.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fclover.coex.tech%2Fassets%2Fblocks%2Fblocks.png" alt="blockly"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks to the onboard camera, you can use OpenCV to recognize objects or people and act accordingly, e.g. program the drone to look for some object, grab it using a gripping device, drop in some other location, etc. Here the drone finds the yellow circle and lands on it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fupoautce6nc4iiq6woeq.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fupoautce6nc4iiq6woeq.gif" alt="Landing recognition gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Awesome, where do I start?
&lt;/h3&gt;

&lt;p&gt;Typical consumer drones (like DJI Mavic) are not open source and it's impossible or at least inconvenient to control them via code. Their frames usually don't support installation of additional components like onboard computer — these drones are meant to be used as they are.&lt;/p&gt;

&lt;p&gt;To use clover&lt;a href="https://github.com/CopterExpress/clover" rel="noopener noreferrer"&gt;🍀&lt;/a&gt; software, you need a drone with a Raspberry Pi 3 or 4 on board — anything with a &lt;a href="https://docs.px4.io/master/en/getting_started/flight_controller_selection.html" rel="noopener noreferrer"&gt;PX4-compatible&lt;/a&gt; flight controller will do.&lt;/p&gt;

&lt;p&gt;
  Hey, what's a flight controller?
  &lt;p&gt;Keeping it simple, a quadcopter consists of a frame, a battery, a flight controller (aka autopilot), motors and their ESCs (electronic speed controllers). A flight controller is a device equipped with microcontroller (like Arduino) and a bunch of sensors: accelerometers, angular rate sensors, magnetometers and barometer. These sensors provide data for microcontroller to calculate drone's current attitude, and with addition of an external positioning data, e.g. GPS, it also determines its position and speed. Using this information and control inputs (commands from the remote control or onboard computer), the flight controller calculates required motor commands and passes them to ESCs, which control drone's motors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F38kfverd3pkos6db1d7h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F38kfverd3pkos6db1d7h.png"&gt;&lt;/a&gt;&lt;/p&gt;






&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/PX4/Firmware" rel="noopener noreferrer"&gt;PX4&lt;/a&gt; is a popular open source autopilot firmware, supported by &lt;a href="https://www.dronecode.org/" rel="noopener noreferrer"&gt;Dronecode Foundation&lt;/a&gt;, a Linux Foundation Collaborative Project. Its architecture is perfect for autonomous flights, controlled by a companion computer instead of a remote, and allows you to extend its functionality easily.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://clover.coex.tech/en/" rel="noopener noreferrer"&gt;Clover docs&lt;/a&gt; contain info on how to connect Raspberry Pi so you can get your drone in the air in no time. Equip your Raspberry Pi with a camera to fly indoors.&lt;/p&gt;

&lt;p&gt;If you don't have a right drone, there are &lt;a href="https://www.kickstarter.com/projects/copterexpress/cloverdrone" rel="noopener noreferrer"&gt;the clover🍀 quadcopter kits&lt;/a&gt;, perfectly suitable for tinkering.&lt;/p&gt;

&lt;h3&gt;
  
  
  What if I'm not ready to mess with the real drone yet?
&lt;/h3&gt;

&lt;p&gt;If you don't have a drone yet, you can still learn how to code them using the &lt;a href="https://clover.coex.tech/en/simulation.html" rel="noopener noreferrer"&gt;simulator&lt;/a&gt;. You can download &lt;a href="https://github.com/CopterExpress/clover_vm/releases" rel="noopener noreferrer"&gt;clover OVF VM image&lt;/a&gt;, run it with Virtualbox or VMware Player and test your code in a virtual environment. It contains Ubuntu, ROS, and a simulated drone, ready to be in the air in a matter of seconds! Here is a short video:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/DMvRzZ80o2s"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;More in-depth documentation on simulation is available in the &lt;a href="https://dev.px4.io/master/en/simulation/index.html" rel="noopener noreferrer"&gt;PX4 docs for developers&lt;/a&gt;. The simulation is extremely useful during the drone development, allowing to create elaborated CI pipelines for the onboard software.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is ROS and how exactly the drone is being controlled?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Robot_Operating_System" rel="noopener noreferrer"&gt;ROS&lt;/a&gt; is the most popular robotics middleware out there. It's a bunch of tools to organize your robot's software: you split your application to separate programs, called &lt;em&gt;nodes&lt;/em&gt;. You can think of nodes as microservices for robots. Nodes can pass messages to one another through &lt;em&gt;topics&lt;/em&gt;, just like microservices do using RabbitMQ/ZeroMQ, and call each others &lt;em&gt;services&lt;/em&gt;, which are essentially &lt;a href="https://en.wikipedia.org/wiki/Remote_procedure_call" rel="noopener noreferrer"&gt;RPCs&lt;/a&gt;. For example, one node can process camera feed, recognizing some objects and posting their coordinates in a topic, while the other can calculate a trajectory to grab these objects and call the "grab" service of the third node, operating the gripping mechanism.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5124amtfcyn1j5xsy67u.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5124amtfcyn1j5xsy67u.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This decentralized architecture lends itself well to robots, providing convenient introspection and debugging. Using &lt;a href="http://wiki.ros.org/rviz" rel="noopener noreferrer"&gt;RViz&lt;/a&gt;, ROS visualization tool, you can visualize the position of your drone, all the recognized objects and any other topics in real time:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8yk0d1n5gff2e8ckjtf8.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8yk0d1n5gff2e8ckjtf8.gif" alt="rviz on competition gif (399h, 10 fps, 6.7M)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This approach also leads to a loosely-coupled architecture — nodes, having defined interfaces, can easily be shared with others. As a result, there's a lot of open source ROS packages on &lt;a href="https://github.com/topics/ros" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; and in the &lt;a href="https://index.ros.org" rel="noopener noreferrer"&gt;ROS Index&lt;/a&gt;. Another advantage of the peer architecture is that nodes can be written using any language which has the ROS client libraries, including C++, Java, Python, Go, C#, Rust, and many others. You can even interact with your nodes from web browser using &lt;a href="http://wiki.ros.org/roslibjs" rel="noopener noreferrer"&gt;ROS JS library&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Your program, written using clover🍀 framework, will run on Raspberry Pi on board. It can use the data from onboard cameras and sensors to determine what to do next — and then issue a command to the drone's flight controller. You can order the drone to fly to a given point, or even directly control its speed or attitude, by calling the ROS services, provided by clover ROS package (more detailed description of available services can be found in &lt;a href="https://clover.coex.tech/en/simple_offboard.html" rel="noopener noreferrer"&gt;the clover docs&lt;/a&gt;). Raspberry Pi will then send the commands to PX4, flight controller firmware, using &lt;a href="https://mavlink.io/en" rel="noopener noreferrer"&gt;MAVLink protocol&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How the drone navigates indoors?
&lt;/h3&gt;

&lt;p&gt;Flying indoors, a drone can't use the GPS to calculate it's position, but thanks to the camera-equipped Raspberry Pi on board it can use computer vision to determine where is it. &lt;a href="https://github.com/CopterExpress/clover" rel="noopener noreferrer"&gt;🍀&lt;/a&gt; framework supports indoor navigation using &lt;a href="https://clover.coex.tech/en/aruco.html" rel="noopener noreferrer"&gt;ArUco markers&lt;/a&gt; (they're like large QR codes) and optical flow.&lt;/p&gt;

&lt;p&gt;When the drone sees an ArUco marker, it can calculate its relative position, which allows to fly with respect to the marker. Let's tell the drone to take position at 1 m above the marker with ID 107:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frame_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;aruco_107&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FCopterExpress%2Fclover%2Fnew-readme%2Fdocs%2Fassets%2Faruco.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FCopterExpress%2Fclover%2Fnew-readme%2Fdocs%2Fassets%2Faruco.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Usually we recommend to use multiple markers, located all over the floor of the flying space, so the drone always sees few of them. Markers can also be placed on some objects like an item to pick up or even a moving platform to land. Here the drone is trying to stay above the marker with ID 225 (yep, just one line of code):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frame_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;aruco_225&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5v80eqey6vybv86lcbdm.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5v80eqey6vybv86lcbdm.gif" alt="Moving ArUco (10 fps, 270h)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When it's not convenient to place ArUco markers, it's possible to use optical flow navigation. It works like the sensor of an optical mouse: the camera is pointed downward and the drone detects how the floor moves relatively to it. It doesn't require any preparation, but allows to execute commands only relative to the current position ("move 2 meters to the right") and not relative to the marker or the room ("fly to where you took off" or "fly to the center of the room").&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FCopterExpress%2Fclover%2Fnew-readme%2Fdocs%2Fassets%2Foptical-flow.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FCopterExpress%2Fclover%2Fnew-readme%2Fdocs%2Fassets%2Foptical-flow.gif" alt="Optical flow gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The optical flow calculation requires knowing the altitude precisely, so a laser rangefinder is a must. Fortunately, they are cheap and tiny these days — even $5 STM VL53L1X is enough.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's next?
&lt;/h3&gt;

&lt;p&gt;The quality and quantity of the beginner's documentation in the field of robotics is often less than desirable, especially in comparison to more popular areas of software development, like web or mobile dev. However, thanks to the efforts of the open source community, in recent years robotics has become an increasingly friendly field. Here are some links in case you decide to dive deeper in the field of the aerial robotics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://wiki.ros.org/" rel="noopener noreferrer"&gt;ROS wiki&lt;/a&gt; covers all the aspects of ROS,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.opencv.org/master/index.html" rel="noopener noreferrer"&gt;OpenCV docs&lt;/a&gt; contain a lot of tutorials on using C++ and Python for computer vision,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PX4 &lt;a href="https://docs.px4.io/master/en/index.html" rel="noopener noreferrer"&gt;user guide&lt;/a&gt; combined with their &lt;a href="https://dev.px4.io/master/en/index.html" rel="noopener noreferrer"&gt;dev guide&lt;/a&gt; provides in-depth information about drones, principles of their software control and PX4 software stack,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://clover.coex.tech/en/" rel="noopener noreferrer"&gt;clover docs&lt;/a&gt; contain a lot of information on clover, ROS, PX4 and their interactions, and you can find webinars and other interesting stuff on &lt;a href="https://www.youtube.com/c/CopterExpressCompany" rel="noopener noreferrer"&gt;our YouTube channel&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have any questions, the open source community is always there to help — ROS has &lt;a href="https://answers.ros.org/" rel="noopener noreferrer"&gt;its Q&amp;amp;A forum&lt;/a&gt;, PX4 project has &lt;a href="https://slack.px4.io" rel="noopener noreferrer"&gt;an enormously active Slack community&lt;/a&gt;, and clover framework has &lt;a href="//t.me/COEXHelpDesk"&gt;a Telegram chat&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I hope you've learned something interesting, whether you become a drone developer or not. :) Stay safe, and stay contributing!&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>python</category>
      <category>opensource</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
