Coder Social home page Coder Social logo

romanoviolet / udacity-model-predictive-controller Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 46.94 MB

An implementation of a Model Predictive Controller based on lectures from the Udacity's Self Driving Care Nano Degree (SDCND) Program

License: MIT License

CMake 0.03% Shell 0.05% C++ 99.06% C 0.86%

udacity-model-predictive-controller's Introduction

Model Predictive Controller

An implementation of a Model Predictive Controller based on lectures from the Udacity's Self Driving Care Nano Degree (SDCND) Program

About

This project implements a Model Predictive Controller (MPC) as required by the Udacity's Self Driving Car Nano-Degree program.

The input data to the Model Predictive Controller is the cross-track error (CTE), current vehicle velocity, and current steering angle, current location of the vehicle, and a sequence of waypoints. The MPC aims to maneuver the car so that it passes as close to the waypoints as possible, and as close to the set speed as possible (the optimization objectives), while avoiding steering or throttle jerks (cnstraints). The waypoints are assumed to be generated by the trajectory planning algorithms implemented separately.

In the provided implementation, the speed set for the MPC to aim for is ~21 m/s (75 km/h, or 47 miles/h). It is possible to tune the MPC controller to aim for higher vehicle speed.

How it Looks

This project involves the Term 2 Simulator which can be downloaded here. Select "MPC Controller" option.

A sample frame from one of the videos as the vehicle negotiates the circuit inside the simulator is shown The yellow line represents the second order polynomial fitted to the provided waypoints, whereas the green line represents the path computed by the optimizer, and is to be followed by the vehicle.

Prerequisites

Ad-verbatim from Udacity's Instructions:

uWebSocketIO Starter Guide

All of the projects in Term 2 and some in Term 3 involve using an open source package called uWebSocketIO. This package facilitates the same connection between the simulator and code that was used in the Term 1 Behavioral Cloning Project, but now with C++. The package does this by setting up a web socket server connection from the C++ program to the simulator, which acts as the host. In the project repository there are two scripts for installing uWebSocketIO - one for Linux and the other for macOS.

Note: Only uWebSocketIO branch e94b6e1, which the scripts reference, is compatible with the package installation. Linux Installation:

From the project repository directory run the script: install-ubuntu.sh

Additonal Dependencies

The MPC project requires installation of following addition dependencies:

  • C++ Algorithmic Differentiation Library and Development Headers, CPPAD
  • Interior Point Optimization Library, IPOpt. Before building the library, please also build and install additional libraries contained in the folder "Third Party", especially, LAPACK, BLAS, and HSL libraries. PDF Instructions
  • MA27 Solver

Once all libraries have been built and installed, the CMakeLists.txt needs to be suitably adapted. A reference CMakeLists.txt.reference has been provided here which contains the working configuration used for developing the MPC project. Pay special attention to line include_directories and link_directories parameters.

Structure of the Project

The project is structured as follows:

  • Folder "src": Contains the core logic required to build the MPC.
  • Folder "Results": Contains a sample video and a screenshot when testing the MPC using the simulator supplied by Udacity. The yellow line represents the polynomial fitted to the provided waypoints, whereas the green line representst the trajectory computed by the optimizer, and is the path to be followed by the vehicle.
  • build.sh: A shell script to build the MPC project.
  • install-ubuntu.sh: A script required for installing dependencies for running the simulator. See the section above on "Prerequisites"
  • run.sh: A shell script to run the binary built using build.sh, and connects to the Udacity's Term 2 simulator. See the section above "How it Looks".

Running the Model Predictive Controller

  • build.sh, followed by
  • run.sh.
  • Start the Udacity Term 2 Simulator, and choose the option "MPC Contoller"

Pending Improvements

  • The speed of the vehicle can be increased even further. Suggestions welcome.

Credits

  • Udacity: Lecturers, and mentors;
  • Internet: for examples and samples.

Disclaimer

Some of the ideas are borrowed and adapted from other people's work.

udacity-model-predictive-controller's People

Contributors

romanoviolet avatar

Watchers

James Cloos avatar  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.