Giter Club home page Giter Club logo

carnd-mpc-project's Introduction

CarND-Controls-MPC

Self-Driving Car Engineer Nanodegree Program

Introduction

This project implements Model Predictive Control to drive a vehicle around the track using a simulator.

The project relies on third party libraries Ipopt and CppAD. Ipopt is a tool used to optimize the control inputs (throttle and steering angle) to find locally optimal values solving a non-linear problem. CppAD is a library used to perform automatic differentiation.

Implementation

Model

We use the kinematic vehicle model which takes vehicle x and y coordinates, angle psi, speed v, cross-track cte and orientation epsi errors as input. The output of the model are optimal steering and throttle values.

kinematic mode equations

The model applies constraints on actuator values to keep angle and throttle within a reasonable range.

The model uses a cost function to find locally optimal values. The cost function optimizes both errors (cross-track and orientation), limits speed to 70 mph, minimizes use of actuators and the value gap between sequential actuations to result in smooth driving.

Timestep Length and Elapsed Duration

The timestep length was set to 10 (N) with elapsed duration between steps set to 0.1s (dt). A short time horizon was chosen since the road frequently curves, changing the environment. A small number of time steps ensured quicker computation by reducing the number of variables to optimize. Timestep set to 0.1s matched system's latency, simplifying calculations to compensate for the latency. Longer timesteps (25) and shorter durations (0.05) caused the vehicle to become quickly unstable.

Model Predictive Control with Latency

The system has a 100ms latency for the vehicle to perform actuations. Not taking latency into account causes the vehicle to swerve off the road since the vehicle acts on outdated data. In order to address this the kinematic model was used to project the vehicle's state (x, y, angle, speed) 100ms into the future using the kinematic model. The future state was then used to find optimal actuator values.

Polynomial Fitting and MPC Preprocessing

In order to simplify calculations the waypoints were transformed from the global coordinates to the vehicle coordinates. This transformation set x, y coordinates and vehicle angle to zero simplifying fitting of the polynomial.

Simulation

The vehicle was able to successfully drive around the track at ~70 mph.

drive around the lap

carnd-mpc-project's People

Contributors

zheniat 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.