Efficient Differentiable Simulation of Articulated Bodies
Yi-Ling Qiao, Junbang Liang, Vladlen Koltun, Ming C. Lin
[Paper] [Video] [Slides] [Code]
Setup
- 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).
- Clone this repo and setup the python environment.
git clone [email protected]: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"
- 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.
- 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
- 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 inpython/exp_throw.py
- By default, simulation records are stored in
meshcat/his/
. This path can be customized by modifying thesync_visual_transforms()
function inexamples/meshcat_urdf_visualizer.h
. - 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.
- Clone the submodule for RL.
git submodule init
git submodule update
- Install the packages for MBPO.
cd diffarti_mbpo/
git checkout master
pip install -e viskit
pip install -e .
- 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
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},
}