Coder Social home page Coder Social logo

danfoa / quadruped-pympc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iit-dlslab/quadruped-pympc

0.0 0.0 0.0 16.98 MB

A model predictive controller for quadruped robots based on the single rigid body model and written in python. Gradient-based (acados) or Sampling-based (jax).

Python 100.00%

quadruped-pympc's Introduction

Overview

This repo contains a model predictive controller based on the single rigid body model and written in Python. It cames in two flavours: gradient-based via acados or sampling-based via jax. The controller is tested on real robots and is compatible with Mujoco.

Features gradient-based mpc:

  • less than 5ms computation on an intel i7-13700H cpu
  • optional integrators for model mismatch
  • optional smoothing for the ground reaction forces
  • optional foothold optimization
  • optional real-time iteration or advanced-step real-time iteration
  • optional zero moment point/center of mass constraints

Features sampling-based mpc:

  • 10000 parallel rollouts in less than 2ms on an nvidia 4050 mobile gpu!
  • optional step frequency adaptation for enhancing robustness
  • implements different strategies: random sampling, mppi, or cemppi
  • different control parametrizations: zero-order, linear splines or cubic splines (see mujoco-mpc)
Experiments with Aliengo
Simulations with Go2

Dependencies

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.

Installation

  1. install miniforge (x86_64)

  2. create an environment using the file in the folder installation choosing between nvidia and integrated gpu, either with or without ros (to run the simulation, you don't need ros!):

    conda env create -f mamba_environment.yml

  3. clone the other submodules:

    git submodule update --init --recursive

  4. activate the conda environment

    conda activate quadruped_pympc_env

  5. go inside the folder acados and compile it pressing:

    mkdir build
    cd build
    cmake -DACADOS_WITH_QPOASES=ON  -DACADOS_WITH_OSQP=ON ..
    make install -j4
    pip install -e ./../interfaces/acados_template
    
  6. 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"
    

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.

How to run

  1. activate the conda environment

    conda activate quadruped_pympc_env
    
  2. go in the folder simulation and press

    python3 simulation_mujoco.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..).

  1. you can interact with the simulation with your mouse to add disturbances, or with the keyboard by pressing
w, s -> add positive or negative forward velocity
a, d -> add positive or negative lateral velocity
q, e -> add positive or negative yaw velocity
0 -> set zero velocities
+, - -> increase or decrease step height

Be aware that this only works if the terminal is in focus, otherwise mujoco will catch the keyboard event.

Citing this work

If you find the work useful, please consider citing:

@article{turrisi2024sampling,
  title={On the Benefits of GPU Sample-Based Stochastic Predictive Controllers for Legged Locomotion},
  author={Giulio Turrisi, Valerio Modugno, Lorenzo Amatucci, Dimitrios Kanoulas, Claudio Semini},
  booktitle={arXiv preprint arXiv:2403.11383},
  year={2024}
}

Maintainer

This repository is maintained by Giulio Turrisi.

quadruped-pympc's People

Contributors

giulioturrisi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.