/diffarticulated

Efficient Differentiable Simulation of Articulated Bodies (ICML2021)

Primary LanguageCApache License 2.0Apache-2.0

Efficient Differentiable Simulation of Articulated Bodies

Yi-Ling Qiao, Junbang Liang, Vladlen Koltun, Ming C. Lin

[Paper] [Video] [Slides] [Code]

Setup

  1. This project is still work-in-progress. It can be built with gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04), cmake 3.17.3, and CUDA 10.2 (only required for MBPO).
  2. Clone this repo and setup the python environment.
git clone git@github.com:YilingQiao/diffarticulated.git
cd diffarticulated
conda env create -f gpu-env.yml
conda activate diffarti_36
export LD_LIBRARY_PATH="$CONDA_PREFIX/lib:$LD_LIBRARY_PATH"
  1. Compile this library.
mkdir build
cd build
cmake ..
make -j
cd ..
python setup.py install

If you do not have the uuid lib, you may install it by apt-get install uuid-dev. We will add uuid to the third_party directory shortly.

  1. Run the examples

Examples

Start visualization

We use meshcat to visualize the simulation. Please run the following command to start a session before runing the simulation.

meshcat-server --open

Run the simulation code

An exmaple of solving inverse physics using the differentiable physics is python/exp_throw.py. Please run

python python/exp_throw.py

and it will optimize the control input in 60 episodes.

Simulation results

  1. When you want to export the simulation results in one frame, you can call world.sync_visual_meshcat(sim_step) in the python code. An example can be found in python/exp_throw.py
  2. By default, simulation records are stored in meshcat/his/. This path can be customized by modifying the sync_visual_transforms() function in examples/meshcat_urdf_visualizer.h.
  3. To convert the simulation records into obj meshes, please run
cd python/results
cp -r ../../meshcat/* ./
python convert_history.py
cd ../..

Before generating new records for conversion, please clean the cache in meshcat/his and meshcat/obj

Learn to throw a marble

To run the demo of throwing a marble,

python python/exp_throw.py

Learn to hit a golf ball

python python/exp_punch.py

Learn the frictional coefficient

python python/exp_car.py

Enhance RL with differentiable physics

We place the RL code in another seperate repo.

  1. Clone the submodule for RL.
git submodule init
git submodule update
  1. Install the packages for MBPO.
cd diffarti_mbpo/
git checkout master
pip install -e viskit
pip install -e .
  1. Run the experiments.

Policy Enhancement

In diffarti_mbpo/, run the command

chmod +x ./run_mbpo.sh
./run_mbpo.sh 8_7 pendulumours

Sample Enhancement

In diffarti_mbpo/, run the command

./run_mbpo.sh final_3 antours

Our Related Repos

Differentiable Soft Body Dynamics Code Paper Differentiable Simulation of Soft Multi-body Systems. Yi-Ling Qiao, Junbang Liang, Vladlen Koltun, Ming C. Lin. (Neurips 2021)

Differentiable Articulated Body Dynamics Code Paper Efficient Differentiable Simulation of Articulated Bodies. Yi-Ling Qiao, Junbang Liang, Vladlen Koltun, Ming C. Lin. (ICML 2021)

Differentiable Dynamics for Rigid Body and Cloth Coupling Code Paper Scalable Differentiable Physics for Learning and Control. Yi-Ling Qiao, Junbang Liang, Vladlen Koltun, Ming C. Lin. (ICML 2020)

Differentiable Cloth Dynamics Code Paper Differentiable Cloth Simulation for Inverse Problems. Junbang Liang, Ming C. Lin, Vladlen Koltun. (NeurIPS 2019)

Acknowledgments

Thanks for the great open-source project tiny-differentiable-simulatior. This repo is derived from tinydiffsim. You might want to try the original tinydiffsim for its templatized auto-differentiation.

Bibtex

@inproceedings{Qiao2021Efficient,
author  = {Qiao, Yi-Ling and Liang, Junbang and Koltun, Vladlen and Lin, Ming C.},
title  = {Efficient Differentiable Simulation of Articulated Bodies},
booktitle = {ICML},
year  = {2021},
}