Code Monkey home page Code Monkey logo

quadcopter-drone-flight-control's Introduction

Autonomous Drone Flight Control

Table of contents

Project Overview

...

Drone Configuration

          Front
     cw  (1) (2)  ccw      x
           \ /           z ↑
            X             \|
           / \             +----→ y
    ccw  (4) (3)  cw
    
Channel Command
1 yaw
2 pitch
3 throttle
4 roll
5 vra

Roadmap

1. Non-autonomous Drone

  • Define basic data structures and workflow
  • pcb design
  • Implement Tx --> Rx communication using interrups
  • Map commands <Throttle, Roll, Pitch, Yaw> into motor signals <m1, m2, m3, m4>
  • Signal smoothening
  • Implement a safe arm/disarm routine
  • Testing

2. Hovering

  • Implement an IMU class for MPU9250
  • Implement a PID class and algorithm
  • Implement a gyro-based hovering maneuver
  • Testing
  • Implement a real time Kalman Filter Algorithm
  • Implement a full hovering maneuver
  • Testing

3. Other Autonomous Maneuver

  • Autonomous take-off and landing

Hardware

  • Frame: S500 glass fiber 480mm
  • Motors: Emax 2216 810kv
  • Propellers: Emax 1045
  • ESC: HAKRC 35A
  • MCU: ATmega 328 (Arduino Nano)
  • IMU: mpu9250 + barometer (10dof sensor)
  • Lipo battery: 3S 5000mAh
  • Radio Tx: Flysky FS-i6X
  • Radio Rx: Flysky X6B

Electronic schematics

Pin Mapping

Board Pin Port Pin Signal Hardware
A4 PC4 SDA IMU
A5 PC5 SCL IMU
D3 PD3 M4 Motor 4
D4 PD4 Ch4 Radio Rx
D5 PD5 Ch3 Radio Rx
D6 PD6 Ch2 Radio Rx
D7 PD7 Ch1 Radio Rx
D9 PB1 M3 Motor 3
D10 PB2 M2 Motor 2
D11 PB3 M1 Motor 1
D12 PB4 Ch5 Radio Rx
                       ATmega328
                    +--------------+           
                    | D13      D12 |<-------------|Ch5| (Radio Rx)
                    | 3.3v     D11 |----> (M1)
                    | Ref      D10 |----> (M2)
                    | A0        D9 |----> (M3)
                    | A1        D8 |
                    | A2        D7 |<-------------|Ch1| (Radio Rx)
                    | A3        D6 |<-------------|Ch2| (Radio Rx)
(MPU9250) |SDA|---->| A4        D5 |<-------------|Ch3| (Radio Rx)
(MPU9250) |SCL|---->| A5        D4 |<-------------|Ch4| (Radio Rx)
                    | A6        D3 |----> (M4)
                    | A7        D2 |
                    | 5v       GND |
                    | RST      RST |
           GND -----| GND       Rx |
          3.3v -----| VIN       Tx |
                    +--------------+

Power Busses

                                 +---------+        +-----------+
                                 | MPU9250 |        | Brushless |
                                 +---+--+--+        |  Motors   |
                                     |  |           +---+--+----+
+======+                             |  |               |  |
|      |-------------- GND ----------+--|----+----------+  |
| LIPO |----(buck)---- 3.3v ------------+    |             |
|  3S  |----(buck)---- 7.3v -----------------|--+          |
|      |------------ 11.1/12.6v -------------|--|----------+
+======+                                     |  |  
                                             |  |   
                                         +---+--+---+ 
                                         | Radio Rx | 
                                         +----------+     

Software

  • Language: C/C++, Matlab
  • IDE: Visual Studio Code w\ PlatformIO
  • Additional libs: Arduino.h, Servo.h

Repository structure

.
├── include
│   ├── atmega328_pin_mapping.h
│   └── README
├── lib
│   ├── drone
│   │   ├── drone.cpp
│   │   └── drone.h
│   ├── MPU9250
│   │   ├── MPU9250.cpp
│   │   └── MPU9250.h
│   ├── PID
│   │   ├── PID.cpp
│   │   └── PID.h
│   └── README
├── platformio.ini
├── README.md
├── src
│   └── main.cpp
└── test
    └── README

Data Structures

Drone:

typedef struct drone{
    uint8_t state;

    int16_t av_throttle;
    int16_t av_roll;
    int16_t av_pitch;
    int16_t av_yaw;

    int16_t throttle[N];
    int16_t roll[N];
    int16_t pitch[N];
    int16_t yaw[N];
    int16_t ch5;

    float roll_coeff;
    float pitch_coeff;
    float yaw_coeff;

    uint16_t m1;
    uint16_t m2;
    uint16_t m3;
    uint16_t m4;

    IMU* imu;   // imu data for control
    PID* pid_x; // pid control on gyro_x
    PID* pid_y; // pid control on gyro_y
} drone;

PID controller:

typedef struct PID{
    float setpoint;
    float Kp, Ki, Kd;
    float dt;
    float err[2];
    float output[2];
    float P, I, D;
    float integral;
    float min, max;
}PID;

Control System

Sketch of control system for full hovering maneuver:

quadcopter-drone-flight-control's People

Contributors

giusenso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.