Skip to content

KyuhwanYeon/Model_Predictive_Control_Ipopt

Repository files navigation

Model predictive control

Model predictive control project for combined longitudinal and lateral control of the autonomous vehicles. It uses udacity vehicle simulator. The simulator sends the reference trajectory and the MPC sends the steering angle and the throttle value to the simulator. They are communicated by uWebSockets. The data specification is written in DATA.md.

If you want to more information of this project, please visit this link. I summarized the project more detail to describe more deeply.

Kinematic model

The kinematic model is used for vehicle model.

kinematic

Reference path

The reference path was fitted with 3-order polynomials

auto coeffs = polyfit(xvals, yvals, 3);

Error states

Three error states are used.

Error

cte is refers the cross track error which is lateral difference with reference path. epsi means the orientation error like above picture. For velocity keeping, velocity error was used.

MPC Formulation

mpc_formulation

This MPC minimize error states, magnitude of inputs and derivative of inputs.

Latency compensation

MPC can consider the latency of inputs. In real vehicle, there is latency of inputs. It means that steering command will not directly applied to the car because there are many delay terms such communication, and mechanic parts. MPC can compensate it easily by use the future reference path.

 const double latency = 0.1; // 100ms latency
 px = px + v * cos(psi) * latency;
 py = py + v * sin(psi) * latency;    

Prediction horizon

Prediction horizon (N*dt) needs to be optimized. I found the values with try and error

Dependencies

Basic Build Instructions

  1. Clone this repo.
  2. Make a build directory: mkdir build && cd build
  3. Compile: cmake .. && make
  4. Run it: ./mpc.

Build with Docker-Compose

The docker-compose can run the project into a container and exposes the port required by the simulator to run.

  1. Clone this repo.
  2. Build image: docker-compose build
  3. Run Container: docker-compose up
  4. On code changes repeat steps 2 and 3.

Running the project

On terminal

mkdir build && cd build
cmake .. && make
./mpc

Open the simulator

1. Open term2_sim_linux/term2_sim.x86_64
2. Select graphic quality
3. Select Project 5: MPC Controller

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published