mpc_python_learn/README.md

53 lines
1.1 KiB
Markdown
Raw Normal View History

2019-11-27 20:30:11 +08:00
# mpc_python
2020-03-04 20:32:29 +08:00
2020-04-08 18:43:38 +08:00
Python implementation of a mpc controller for path tracking using **[CVXPY](https://www.cvxpy.org/)**.
2020-03-04 20:32:29 +08:00
## About
The MPC is a model predictive path following controller which does follow a predefined reference path Xref and Yref by solving an optimization problem. The resulting optimization problem is shown in the following equation:
2020-04-08 00:09:13 +08:00
![](img/quicklatex1.png)
2020-03-04 20:32:29 +08:00
The vehicle dynamics are described by the differential drive model:
2020-04-08 00:09:13 +08:00
![](img/quicklatex2.png)
2020-03-04 20:32:29 +08:00
The state variables of the model are:
2020-04-08 00:09:13 +08:00
* **x** coordinate of the robot
* **y** coordinate of the robot
* **theta** heading of the robot
2020-03-04 20:32:29 +08:00
The inputs of the model are:
2020-04-08 00:09:13 +08:00
* **v** linear velocity of the robot
* **w** angular velocity of the robot
2020-03-04 20:32:29 +08:00
## Demo
2020-04-08 18:43:38 +08:00
The MPC implementation is tested using **[bullet](https://pybullet.org/wordpress/)** physics simulator.
![](img/Turtlebot.png)
Results:
2020-03-04 20:32:29 +08:00
![](img/demo.gif)
2020-04-08 18:43:38 +08:00
To run the pybullet demo:
```bash
python3 mpc_demo/mpc_demo_pybullet.py
```
To run the simulation-less demo:
2020-03-04 20:32:29 +08:00
```bash
2020-04-08 18:43:38 +08:00
python3 mpc_demo/mpc_demo_pybullet.py
2020-03-04 20:32:29 +08:00
```
## Requirements
```bash
pip3 install --user --requirement requirements.txt
```