Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Machine Learning for Drones

  1. #1
    Junior Member
    Join Date
    Apr 2020

    Machine Learning for Drones

    Hey I am totally new to developing control systems for drones so forgive my mistakes.

    But I require a micro controller on which I can use a machine learning program to ensure stable and adaptive flight in drones.
    If anyone can advise me on this I would be very grateful.

    Thank you very much

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Well, there are a few ways you can go about this, and the usual solution is not to use ML.

    Drones are normally stabilized by using an IMU (inertial measuring unit) that produces a unit vector describing which way is down.

    If it returns <0, 0, -1> (assuming an Euler vector where Z is the up-down dimension), then the thing is exactly level. If it starts to wander off, the controller reads this and subtly changes the torque output of the motors to counter the effect. This must be done continuously because the drone, being light, is very susceptible to any turbulence in the air. It is very common to get a sudden burst of lift, or a sickening drop, at low altitudes. The effect gets worse closer to the ground as the air is burbling around trees and buildings and so on, and that effect is why landing is the second most dangerous phase of flight. Above a few hundred feet, there are things like thermals and ridge lift to consider as well.

    Because the response has to be proportional to the deviation, the controller doesn't just crank up one of the motors to maximum. It has to be just right. In order to accomplish this, there are a couple of algorithms you can use.

    One is PID, which gives you three variables to fiddle with, and which took me a long time to really get an instinctive understanding for. (I used it to control 3D printer bed temperature, which is difficult because the bed has a lot of thermal inertia and you will see a response to increased or decreased heating some seconds after you do it.) PID can be rough to grapple with because changing any variable changes the behavior of the others, and you can get into some exhausting levels of recursion (in your mind, not in the code) until you have it down pat. PID was initially designed to keep massive ships on course despite drift imparted by currents, and it's good at capturing effects in systems with (sometimes massive) inertia. Most industrial controllers that have any use for that functionality use PID, as far as I know, and if you buy an auto-leveler for a drone it's likely to use that algorithm.

    Another control scheme is dead-time control, which in practice is much simpler to understand because there are only two variables: maximum output and deadtime, which is the amount of time it takes from initial input to the knee of the response curve. (In Repetier this means how long it takes for the heating element to significantly respond, but in a drone application it would be how long it takes for the airframe to respond after motor torque is adjusted by the control algorithm.)

    It is possible that you could replace this with a machine learning model that knows how to stabilize the drone during normal bursts of turbulence, but perhaps can "smell" certain patterns that develop over a span of milliseconds to seconds. You could alternately use ML to tune either PID or deadtime algorithms. It would probably be overkill for deadtime, because there is only one variable to tweak, and you can do that yourself pretty easily.

    In any case, the solution will involve processing the unit vector from the IMU into meaningful adjustments to motor torque.

    The Teensy 4 series would be an obvious choice if you want to do serious heavy calculations. Probably a 4.1 so you can use a micro-SD card. The 3.x series might be capable enough, but if you want to use bigger matrices the extra CPU power and tightly-coupled RAM will be a big help. I think it can be overclocked up to 1GHz (requires cooling) if needed. It will run at 600MHz without cooling.

    What is your experience with drones and machine learning so far?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts