From 936dcd3642a2aaccb6d4a355080f1ad80ef18b55 Mon Sep 17 00:00:00 2001 From: mcarfagno Date: Thu, 21 Jul 2022 14:14:14 +0100 Subject: [PATCH] added conda env file, README cleanup --- README.md | 39 +++++++++++++------------- env.yml | 22 +++++++++++++++ mpc_pybullet_demo/mpc_demo_pybullet.py | 2 +- 3 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 env.yml diff --git a/README.md b/README.md index 8baeba5..8579b5c 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,35 @@ # 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. -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 -### 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 -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 -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 1. State space model derivation -> analytical and numerical derivaion of the model 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**! -## Results +### Results Racing car model is from: *https://github.com/erwincoumans/pybullet_robots*. @@ -67,21 +71,16 @@ Results: ![](img/demo.gif) -To run the pybullet demo: +### Requirements + +The environment can be repoduced via [conda](https://www.anaconda.com/products/distribution): ```bash -python3 mpc_demo/mpc_demo_pybullet.py +conda env create -f env.yml +conda activate simulation ``` -To run the simulation-less demo: - -```bash -python3 mpc_demo/mpc_demo_pybullet.py -``` - -## Requirements - -The dependencies can be installed using pip (): +The dependencies for just the python scripts can also be installed using `pip`: ```bash pip3 install --user --requirement requirements.txt ``` diff --git a/env.yml b/env.yml new file mode 100644 index 0000000..3f264df --- /dev/null +++ b/env.yml @@ -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 diff --git a/mpc_pybullet_demo/mpc_demo_pybullet.py b/mpc_pybullet_demo/mpc_demo_pybullet.py index a66a08c..03efa5d 100644 --- a/mpc_pybullet_demo/mpc_demo_pybullet.py +++ b/mpc_pybullet_demo/mpc_demo_pybullet.py @@ -227,7 +227,7 @@ def run_sim(): y_history = [] time.sleep(0.5) - input("Press Enter to continue...") + input("\033[92m Press Enter to continue... \033[0m") while 1: