Git Product home page Git Product logo

deepcontrol's Introduction

This repository if for deepControl.

The Deep Neural Network (DNN) Controller is a two hidden layer Neural Network with 64 neurons in each layer.

The quadrotor state-space equation is a 12 dimensional vector

s  = [x,y,z, vx,vy,vz, roll,pitch,yaw, rs,ps,ys]

where

  1. x,y,z is the position
  2. vx, vy, vz is the linear velocities
  3. roll,pitch,yaw are the Euler Angles
  4. rs,ps,ys are the angular velocities

This high level controller on the quadrotor takes in the state and outputs the controls:

u = [roll_commanded, pitch_commanded, yaw_rate, thrust_commanded]

The dynamics of the quadrotor dictate that the yaw motion is decoupled from the roll and pitch motion. Therefore we keep the yaw as constant. The DNN takes in the state and outputs the three controls: [roll_commanded, pitch_commanded, thrust_commanded]

The DNN weights are learned by using supervised learning. The data for learning is generated by using Model Predictive Controller running on the quadrotor.

The learned controller can be implemented in either C++ or python.

Structure of DNN

The DNN has 2 hidden layers each with 64 neurons.

Input

The desired position is denoted by [x_des, y_des, z_des]. The input to the DNN is given as

X = [x_des-x, y_des-y, z_des-z, vx, vy, vz, roll, pitch, rs, ps]

This input is fed to the first layer:

o1 = relu(W1.X + B1)

where relu is the activation function, W1 is the weight matrix and B1 is the bias, of layer 1.

Similarly for the 2nd layer.

o2 = relu(W2.o1 + B2)

Output

The output from the DNN controller is [roll, pitch, thrust]

For the output layer the activation function used is tanh as it bounds the output between [-1, 1].

y = tanh(W3.o2 + B3)

The thrust is output is scaled up according to the weight of the quadrotor.

The tracking performance of the DNN is at par with the MPC controller.

Python

The python/mav_deepControl.py is the controller written in python with controller weight in python/wt

C++

The C++ controller is located at cpp/src/mav_deepControl.cpp with weights in cpp/include. The C++ controller uses Eigen libraries for matrix arithmetic.

Links

Installation

Requirements ROS-Kinetic, catkin tools, Eigen3

  1. Install catkin tools
     $ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list'
     $ wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
  2. Clone the deepControl repository
    git clone https://github.com/pratyusv/deepControl.git
    cd ./deepControl
    git submodule update --init --recursive
  3. Build the catkin workspace
    catkin build

Usage

Ensure that the ros environment is included in the bash profile of the shell. If it is not included add to ~/.bashrc

source /opt/ros/kinetic/setup.sh

Go to the catkin workspace of the deepControl folder.

cd ./deepControl/catkin_ws/src

All the terminals in the below step are created from the above path.

  1. Launch the rotors_simulator in the terminal

    roslaunch rotors_gazebo mav.launch mav_name:=f450

    Unpause the physics of the gazebo by clicking on the play button.

  2. In a new Terminal launch the Non-Linear MPC controller:

    roslaunch mav_nonlinear_mpc mav_nonlinear_mpc_sim.launch mav_name:=f450

    The mpc commands are intially published on the topic: /f450/command/roll_pitch_yawrate_thrust. We remap these controls to topic /f450/rpyth. These frees up the /f450/command/roll_pitch_yawrate_thrust topic to publish the DNN controlls.

    This remapping is done in the mav_nonlinear_mpc_sim.launch file.

    <remap from="command/roll_pitch_yawrate_thrust" to="rpyth"/>
  3. In a new terminal run the trajectory generator.

     roslaunch mav_trajectory_generation_ros my_node.launch mav_name:=f450
  4. In a new terminal run the DNN controller.

     cd ./dnn_mpc
     python follow_xy.py
  5. In a new terminal kill the tracker rosnode. The quadorotor will start following the trajectory once the tracker node is killed.

    rosnode kill /f450/tracking_node

deepcontrol's People

Contributors

pratyusv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

benzpeng

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.