Skip to content

Nonlinear Model Predictive Control for Self-Driving Vehicles based on Local Sequential Quadratic Programming by recursively calling ProxQP solver.

License

Notifications You must be signed in to change notification settings

simone-contorno/mynmpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyNMPC

Nonlinear Model Predictive Control (NMPC) for Self-Driving Vehicles

European Master on Advanced RObotics (EMARO+) Thesis

Author: Simone Contorno


Introduction

An introduction to this repository.
Go to Introduction

How it works

A rapid description of how the program works (pseudo-code).
Go to How it works

Prerequisites

Needed prerequisites to correctly install.
Go to Prerequisites

Installation

How to install.
Go to Installation

Execution

How to execute the examples.
Go to Execution

Improvements

Possible improvements.
Go to Improvements

Conclusion

Brief conclusion and BibTeX for citing.
Go to Conclusion

Introduction

This repository provides a Nonlinear Model Predictive Control (NMPC) program written in C++.
The implemented NMPC uses the Sequential Quadratic Programming (SQP) approach by recursively calling the ProxQP solver.
I developed this program for my Master Thesis in Robotics Engineering (University of Genoa) at the LS2N (Laboratoire des sciences du numérique de Nantes) during my 1-year period at the École Centrale de Nantes with the EMARO+ double degree program.

How it works

The program runs in a ROS 2 (Robot Operating System) environment. In particular, it has been developed using the Foxy version.
It is structured over 3 levels:

  1. Model: a model file must be defined to describe the vehicle (e.g. unicycle or bicycle).
  2. MPC: a MPC file must be defined to describe the tuning of the Model Predictive Control (e.g. weight matrices).
  3. Controller: a control file must be written in order to opportunely use the model and MPC files to define the problem, and then managing the related data to recursively solve it and gives the optimal control input to the vehicle.

Pseudo-code

ProxQP

FUNCTION init
    SET model info
    SET equality constraints
    SET inequality constraints

    INITIALIZE QP problem
    
    SET Hessian matrix
    
    DEFINE sparse problem
    DEFINE dense problem
ENDFUNCTION

FUNCTION solve WITH horizon states,
                    horizon controls,
                    last control,
                    slack variable,
                    horizon state goals,
                    horizon control goals

    SET linear coefficients vector
    SET equality constraints matrix
    SET equality constraints bounds vector
    SET inequality constraints matrix
    SET inequality constraints bounds vector

    SOLVE sparse OR dense problem

    UPDATE decision variables
    
    RETURN optimal decision variables and QP info
ENDFUNCTION

MPC

FUNCTION solve
    UPDATE state and control 
    DO SQP
        SOLVE ProxQP sub-problem
        UPDATE state, control, and slack variable 
    UNTIL problem is solved || max. SQP iterations reached

    UPDATE first control input 

    RETURN optimal states and controls
ENDFUNCTION

Other information:

Prerequisites

  1. Install the Eigen3 library:
    sudo apt install libeigen3-dev
  2. Install the ProxQP solver.

Installation

  1. Go into the src folder of your ROS 2 workspace.
  2. Download this repository:
    git clone https://github.com/simone-contorno/mynmpc
  3. Go into the root folder of your ROS 2 workspace and build it:
    colcon build --packages-select mynmpc

Execution

To try the program you first need to install a visualizer provided by the mobro_sim package based on the simple_launch and map_simulator ones:

  1. Go into the src folder of your ROS 2 workspace.
  2. Download these repositories:
    git clone https://github.com/oKermorgant/simple_launch
    git clone https://github.com/oKermorgant/map_simulator
    git clone https://github.com/simone-contorno/mobro_sim
  3. Go into the root folder of your ROS 2 workspace and build them:
    colcon build --packages-select simple_launch map_simulator mobro_sim

Then, you need to switch to the simulation branch and follow the instructions to run the controller example.
Switching to the rosbot branch you can also have a test for the ROSbot 2R by Husarion.

Improvements

A discussion about the possible improvements can be read here in Section "Possible future works".

Conclusion

I hope that this work can be useful to your purposes, if you have any questions feel free to ask.
Videos of the given examples can be found on my YouTube channel.
To cite this work please use the following BibTeX:

@misc{MyNMPC,
    TITLE       = {MyNMPC: A Nonlinear Model Predictive Control for Self-Driving Vehicles},
    AUTHOR      = {Simone Contorno},
    YEAR        = {2023},
    URL         = {https://github.com/simone-contorno/mynmpc}
}

About

Nonlinear Model Predictive Control for Self-Driving Vehicles based on Local Sequential Quadratic Programming by recursively calling ProxQP solver.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published