An introduction to this repository.
Go to Introduction
A rapid description of how the program works (pseudo-code).
Go to How it works
Needed prerequisites to correctly install.
Go to Prerequisites
How to install.
Go to Installation
How to execute the examples.
Go to Execution
Possible improvements.
Go to Improvements
Brief conclusion and BibTeX for citing.
Go to Conclusion
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.
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:
- Model: a model file must be defined to describe the vehicle (e.g. unicycle or bicycle).
- MPC: a MPC file must be defined to describe the tuning of the Model Predictive Control (e.g. weight matrices).
- 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.
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
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:
- Install the Eigen3 library:
sudo apt install libeigen3-dev
- Install the ProxQP solver.
- Go into the src folder of your ROS 2 workspace.
- Download this repository:
git clone https://github.com/simone-contorno/mynmpc
- Go into the root folder of your ROS 2 workspace and build it:
colcon build --packages-select mynmpc
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:
- Go into the src folder of your ROS 2 workspace.
- 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
- 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.
A discussion about the possible improvements can be read here in Section "Possible future works".
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}
}