Giter Club home page Giter Club logo

3.controller_for_drone's Introduction

Controller for Drone

In this project, I have implemented the PID controller for Drone and tuning of controller for different scenarios/flying conditions. Successfully tested developed and tuned controller to perform below scenario:

All the steps of implementations are explained in writeup.md file.

For easy navigation throughout this document, here is an outline:

Development Environment Setup

The first step is to download or clone this repository.

git clone https://github.com/Ashutosh-Badave/Controller_for_drone.git 

Once you have the code for the simulator, you will need to install the necessary compiler and IDE necessary for running the simulator.

Here are the setup and install instructions for Linux and Clion:

Linux

For Linux, the recommended IDE is QtCreator.

  1. Download and install QtCreator.
  2. Open the .pro file from the <simulator>/project directory.
  3. Compile and run the project (using the tab Build select the qmake option. You should see a single quadcopter, falling down.

NOTE: You may need to install the GLUT libs using sudo apt-get install freeglut3-dev

Advanced Versions

These are some more advanced setup instructions for those of you who prefer to use a different IDE or build the code manually. Note that these instructions do assume a certain level of familiarity with the approach.

CLion IDE

I have used CLion IDE for development , I have included the necessary CMakeLists.txt file to build the simulation. Build the project and run, simulator window will pop-up on screen.

CMake on Linux

For those of you interested in doing manual builds using cmake, we have provided a CMakeLists.txt file with the necessary configuration.

NOTE: This has only been tested on Ubuntu 16.04, however, these instructions should work for most linux versions. Also note that these instructions assume knowledge of cmake and the required cmake dependencies are installed.

  1. Create a new directory for the build files:
cd FCND-Controls-CPP
mkdir build
  1. Navigate to the build directory and run cmake and then compile and build the code:
cd build
cmake ..
make
  1. You should now be able to run the simulator with ./CPPSim and you should see a single quadcopter, falling down.

Simulator Walkthrough

Now that you have all the code on your computer and the simulator running, let's walk through some of the elements of the code and the simulator itself.

The code

For the project, the majority of code is written in src/QuadControl.cpp. This file contains all of the code for the controller that I have developed.

I have created writeup file, in which I have elaborate how I implemented the code and tuned the different parameters for successfully complete the project and flying of drone in different scenarios.

All the configuration files for your controller and the vehicle are in the config directory. For example, for all your control gains and other desired tuning parameters, there is a config file called QuadControlParams.txt set up for you. An import note is that while the simulator is running, you can edit this file in real time and see the affects your changes have on the quad!

The syntax of the config files is as follows:

  • [Quad] begins a parameter namespace. Any variable written afterwards becomes Quad.<variablename> in the source code.
  • If not in a namespace, you can also write Quad.<variablename> directly.
  • [Quad1 : Quad] means that the Quad1 namespace is created with a copy of all the variables of Quad. You can then overwrite those variables by specifying new values (e.g. Quad1.Mass to override the copied Quad.Mass). This is convenient for having default values.

You will also be using the simulator to fly some difference trajectories to test out the performance of your C++ implementation of your controller. These trajectories, along with supporting code, are found in the traj directory of the repo.

The Simulator

In the simulator window itself, you can right click the window to select between a set of different scenarios that are designed to test the different parts of your controller.

The simulation (including visualization) is implemented in a single thread. This is so that you can safely breakpoint code at any point and debug, without affecting any part of the simulation.

Due to deterministic timing and careful control over how the pseudo-random number generators are initialized and used, the simulation should be exactly repeatable. This means that any simulation with the same configuration should be exactly identical when run repeatedly or on different machines.

Vehicles are created and graphs are reset whenever a scenario is loaded. When a scenario is reset (due to an end condition such as time or user pressing the โ€˜Rโ€™ key), the config files are all re-read and state of the simulation/vehicles/graphs is reset -- however the number/name of vehicles and displayed graphs are left untouched.

When the simulation is running, you can use the arrow keys on your keyboard to impact forces on your drone to see how your controller reacts to outside forces being applied.

Keyboard / Mouse Controls

There are a handful of keyboard / mouse commands to help with the simulator itself, including applying external forces on your drone to see how your controllers reacts!

  • Left drag - rotate
  • X + left drag - pan
  • Z + left drag - zoom
  • arrow keys - apply external force
  • C - clear all graphs
  • R - reset simulation
  • Space - pause simulation

Testing it Out

When you run the simulator, you'll notice your quad is getting stable in few seconds. This is due to its a first scenario "1_Intro".

your simulation should look a little like this:

If it does not look like this then adjust the mass by small value in config file.

Once its stable, you can change the scenario by right clicking on simulator window and select another scenario, also you can plot different graphs for analysis purpose. Enjoy exploring.

Contributors

Thanks to Fotokite for the initial development of the project code and simulator.

3.controller_for_drone's People

Contributors

ashutosh-badave 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.