Gradient-based MPC: It uses CasADI to define the model and acados to solve the optimal control problem. Sampling-based MPC: jax for both. The simulation environment is based on Mujoco.
You can install this repo with Pixi (preferred) or Conda.
-
install pixi
-
create the environment:
pixi install
pixi shell- go to Common Steps section
-
install miniforge (x86_64 or arm64 depending on your platform)
-
create an environment using the file in the folder installation choosing between nvidia and integrated gpu:
conda env create -f mamba_environment.yml
conda activate quadruped_pympc_env- go to Common Steps section
-
clone the other submodules:
git submodule update --init --recursive -
go inside the folder acados and compile it pressing:
cd quadruped_pympc/acados/ mkdir build cd build cmake -DACADOS_WITH_SYSTEM_BLASFEO:BOOL=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .. make install -j4 pip install -e ./../interfaces/acados_template -
inside the file .bashrc, given your path_to_acados, put:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/path_to_acados/lib" export ACADOS_SOURCE_DIR="/path_to_acados"Notice that if you are using Mac, you should modify the file .zshrc adding
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/path_to_acados/lib" export ACADOS_SOURCE_DIR="/path_to_acados"
The first time you run the simulation with acados, in the terminal you will be asked to install tera_render. You should accept to proceed.
-
go to Quadruped-PyMPC initial folder and install it:
pip install -e .
-
activate your pixi or conda environment
-
go in the main Quadruped-PyMPC folder and press
python3 simulation/simulation.py
In the file config.py, you can set up the robot, the mpc type (gradient, sampling..), its proprierties (real time iteration, sampling type, foothold optimization..), and other simulation params (reference, gait type..).
- you can interact with the simulation with your mouse to add disturbances, or with the keyboard by pressing
arrow up, arrow down -> add positive or negative forward velocity
arrow left, arrow right -> add positive or negative yaw velocity
ctrl -> set zero all velocities
-
activate your pixi or conda environment
-
you can run now the script
python3 ros2/run_controller.py -
if you want to test the above node with a simulator, for example to test ros2 delay, you can run
python3 ros2/run_simulator.py -
joystick
ros2 launch teleop_twist_joy teleop-launch.py joy_config:='xbox' -
general commands from terminal available here
-
for a real-robot deployment, use a nice state estimator