updated README to latest version
parent
ef175816d8
commit
271b220277
|
@ -1,36 +1,53 @@
|
||||||
# mpc_python
|
# mpc_python
|
||||||
|
|
||||||
Python implementation of mpc controller for path tracking.
|
Python implementation of a mpc controller for path tracking using **[CVXPY](https://www.cvxpy.org/)**.
|
||||||
|
|
||||||
## About
|
## 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:
|
The MPC is a model predictive path following controller which does follow a predefined reference by solving an optimization problem. The resulting optimization problem is shown in the following equation:
|
||||||
|
|
||||||
![](img/quicklatex1.png)
|
![](img/quicklatex_equation.png)
|
||||||
|
|
||||||
The vehicle dynamics are described by the differential drive model:
|
The terns of the cost function are the sum of the **reference tracking error**, **heading effort** and **actuaction rate of change**.
|
||||||
|
|
||||||
|
Where R,P,Q are the cost matrices used to tune the response.
|
||||||
|
|
||||||
|
The vehicle model is described by the bicycle kinematics model using the state space matrices A and B:
|
||||||
|
|
||||||
![](img/quicklatex2.png)
|
![](img/quicklatex2.png)
|
||||||
|
|
||||||
The state variables of the model are:
|
The state variables **(x)** of the model are:
|
||||||
|
|
||||||
* **x** coordinate of the robot
|
* **x** coordinate of the robot
|
||||||
* **y** coordinate of the robot
|
* **y** coordinate of the robot
|
||||||
|
* **v** velocuty of the robot
|
||||||
* **theta** heading of the robot
|
* **theta** heading of the robot
|
||||||
|
|
||||||
The inputs of the model are:
|
The inputs **(u)** of the model are:
|
||||||
|
|
||||||
* **v** linear velocity of the robot
|
* **a** linear acceleration of the robot
|
||||||
* **w** angular velocity of the robot
|
* **delta** steering angle of the robot
|
||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
|
|
||||||
|
The MPC implementation is tested using **[bullet](https://pybullet.org/wordpress/)** physics simulator. Racing car model is from: *https://github.com/erwincoumans/pybullet_robots*.
|
||||||
|
|
||||||
|
![](img/f10.png)
|
||||||
|
|
||||||
|
Results:
|
||||||
|
|
||||||
![](img/demo.gif)
|
![](img/demo.gif)
|
||||||
|
|
||||||
To run the demo:
|
To run the pybullet demo:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python3 mpc_demo/main.py
|
python3 mpc_demo/mpc_demo_pybullet.py
|
||||||
|
```
|
||||||
|
|
||||||
|
To run the simulation-less demo:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python3 mpc_demo/mpc_demo_pybullet.py
|
||||||
```
|
```
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
@ -38,3 +55,8 @@ python3 mpc_demo/main.py
|
||||||
```bash
|
```bash
|
||||||
pip3 install --user --requirement requirements.txt
|
pip3 install --user --requirement requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## References
|
||||||
|
* [mpc paper](https://borrelli.me.berkeley.edu/pdfpub/IV_KinematicMPC_jason.pdf)
|
||||||
|
* [pythonrobotics](https://github.com/AtsushiSakai/PythonRobotics/)
|
||||||
|
* [pybullet](https://pybullet.org/wordpress/)
|
11
README.md
11
README.md
|
@ -6,11 +6,11 @@ Python implementation of a mpc controller for path tracking using **[CVXPY](http
|
||||||
|
|
||||||
The MPC is a model predictive path following controller which does follow a predefined reference by solving an optimization problem. The resulting optimization problem is shown in the following equation:
|
The MPC is a model predictive path following controller which does follow a predefined reference by solving an optimization problem. The resulting optimization problem is shown in the following equation:
|
||||||
|
|
||||||
![](img/quicklatex1.png)
|
![](img/quicklatex_equation.png)
|
||||||
|
|
||||||
The terns of the cost function are the sum of the **cross-track error**, **heading error**, **velocity error** and **actuaction effort**.
|
The terns of the cost function are the sum of the **reference tracking error**, **heading effort** and **actuaction rate of change**.
|
||||||
|
|
||||||
Where R,P,K,Q are the cost matrices used to tune the response.
|
Where R,P,Q are the cost matrices used to tune the response.
|
||||||
|
|
||||||
The vehicle model is described by the bicycle kinematics model using the state space matrices A and B:
|
The vehicle model is described by the bicycle kinematics model using the state space matrices A and B:
|
||||||
|
|
||||||
|
@ -55,3 +55,8 @@ python3 mpc_demo/mpc_demo_pybullet.py
|
||||||
```bash
|
```bash
|
||||||
pip3 install --user --requirement requirements.txt
|
pip3 install --user --requirement requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## References
|
||||||
|
* [mpc paper](https://borrelli.me.berkeley.edu/pdfpub/IV_KinematicMPC_jason.pdf)
|
||||||
|
* [pythonrobotics](https://github.com/AtsushiSakai/PythonRobotics/)
|
||||||
|
* [pybullet](https://pybullet.org/wordpress/)
|
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -634,7 +634,7 @@
|
||||||
"$\n",
|
"$\n",
|
||||||
"\\begin{equation}\n",
|
"\\begin{equation}\n",
|
||||||
"\\begin{aligned}\n",
|
"\\begin{aligned}\n",
|
||||||
"\\min_{} \\quad & \\sum^{t+T-1}_{j=t} (x_{j} - x_{j,ref})^TQ(x_{j} - x_{j,ref}) + \\sum^{t+T-1}_{j=t+1} u^T_{j}Ru_{j} + (u_{j} - u_{j-1})^T(u_{j} - u_{j-1}) \\\\\n",
|
"\\min_{} \\quad & \\sum^{t+T-1}_{j=t} (x_{j} - x_{j,ref})^TQ(x_{j} - x_{j,ref}) + \\sum^{t+T-1}_{j=t+1} u^T_{j}Ru_{j} + (u_{j} - u_{j-1})^TP(u_{j} - u_{j-1}) \\\\\n",
|
||||||
"\\textrm{s.t.} \\quad & x(0) = x0\\\\\n",
|
"\\textrm{s.t.} \\quad & x(0) = x0\\\\\n",
|
||||||
" & x_{j+1} = Ax_{j}+Bu_{j} \\quad \\textrm{for} \\quad t<j<t+T-1 \\\\\n",
|
" & x_{j+1} = Ax_{j}+Bu_{j} \\quad \\textrm{for} \\quad t<j<t+T-1 \\\\\n",
|
||||||
" & u_{MIN} < u_{j} < u_{MAX} \\quad \\textrm{for} \\quad t<j<t+T-1 \\\\\n",
|
" & u_{MIN} < u_{j} < u_{MAX} \\quad \\textrm{for} \\quad t<j<t+T-1 \\\\\n",
|
||||||
|
|
Loading…
Reference in New Issue