added conda env file, README cleanup

master
mcarfagno 2022-07-21 14:14:14 +01:00
parent 7bcd72cc66
commit 936dcd3642
3 changed files with 42 additions and 21 deletions

View File

@ -1,31 +1,35 @@
# mpc_python # mpc_python
I keep here my Jupyter notebooks on R&D on Model Predictive Control applyied to path-following problems in driverless vehicles. Includes also a Pybullet simulation to showcase the results. I keep here my Jupyter notebooks on R&D on Model Predictive Control applyied to path-following problems in driverless vehicles. Includes also a Pybullet simulation to showcase the results.
This mainly uses **[CVXPY](https://www.cvxpy.org/)** as a framework. This repo contains code from other projecs, check them out in thr special thanks section. This mainly uses **[CVXPY](https://www.cvxpy.org/)** as a framework. This repo contains code from other projecs, check them out in the special thanks section.
## Contents ## Contents
### Python Scripts ### Usage
The settings for tuning the MPC controller are in the **mpc_config** class. From within the `mpc_pybullet_demo` directory:
Scripts for running the algorithm with/without the pybullet simulation, *these require some tidy up* :/ * To run the pybullet demo:
```bash ```bash
python mpc_pybullet_demo/mpc_demo_pybullet.py python3 mpc_demo_pybullet.py
``` ```
A simpler demo wich does not use pybullet is also provided, this is useful for debugging * To run the simulation-less demo (simpler demo that does not use pybullet, useful for debugging):
```bash ```bash
python mpc_pybullet_demo/mpc_demo_pybullet.py python3 mpc_demo_pybullet.py
``` ```
In both cases the script will promt the user for `enter` before starting the demo.
The settings for tuning the MPC controller are in the **[mpc_config](./mpc_pybullet_demo/mpcpy/mpc_config.py)** class.
### Jupyter Notebooks ### Jupyter Notebooks
1. State space model derivation -> analytical and numerical derivaion of the model 1. State space model derivation -> analytical and numerical derivaion of the model
2. MPC -> implementation and testing of various tweaks/improvements 2. MPC -> implementation and testing of various tweaks/improvements
3. Obstacle Avoidance -> Using halfplane constrains to avaoid track collisions -> Sill work in progress 3. Obstacle Avoidance -> Using halfplane constrains to avaoid track collisions -> Sill **work in progress**!
<!--nobody cares about this <!--nobody cares about this
## About ## About
@ -55,7 +59,7 @@ The inputs **(u)** of the model are:
* **delta** steering angle of the robot * **delta** steering angle of the robot
--> -->
## Results ### Results
Racing car model is from: *https://github.com/erwincoumans/pybullet_robots*. Racing car model is from: *https://github.com/erwincoumans/pybullet_robots*.
@ -67,21 +71,16 @@ Results:
![](img/demo.gif) ![](img/demo.gif)
To run the pybullet demo:
### Requirements
The environment can be repoduced via [conda](https://www.anaconda.com/products/distribution):
```bash ```bash
python3 mpc_demo/mpc_demo_pybullet.py conda env create -f env.yml
conda activate simulation
``` ```
To run the simulation-less demo: The dependencies for just the python scripts can also be installed using `pip`:
```bash
python3 mpc_demo/mpc_demo_pybullet.py
```
## Requirements
The dependencies can be installed using pip ():
```bash ```bash
pip3 install --user --requirement requirements.txt pip3 install --user --requirement requirements.txt
``` ```

22
env.yml Normal file
View File

@ -0,0 +1,22 @@
name: simulation
channels:
- conda-forge
- defaults
dependencies:
- ipython
- ipywidgets
- jupyterlab
- jupyterlab_server
- nb_conda_kernels
- nbconvert
- nbformat
- pip
- python>=3.8
- numpy
- sympy
- cvxpy
- matplotlib
- matplotx
- pip:
- pybullet
- black==22.3.0

View File

@ -227,7 +227,7 @@ def run_sim():
y_history = [] y_history = []
time.sleep(0.5) time.sleep(0.5)
input("Press Enter to continue...") input("\033[92m Press Enter to continue... \033[0m")
while 1: while 1: