DanielTakeshi / gym-cloth

Code for IROS 2020 paper: https://arxiv.org/abs/1910.04854
26 stars 11 forks source link

Gym Cloth

Quick logistics overview: this is one of the code bases used in our paper "Deep Imitation Learning of Sequential Fabric Smoothing From an Algorithmic Supervisor" with arXiv here and project website here. The arXiv version will have the most up-to-date version of the paper.


This creates a gym environment based on our cloth simulator. The path directory is structured following standard gym conventions, and we also include our .pyx files here for Cython compilation.

Platforms tested:

Please use Python 3.6.

Installation and Code Usage

  1. Make a new virtualenv or conda env. For example, if you're using conda envs, run this to make and then activate the environment:

    conda create -n py3-cloth python=3.6
    conda activate py3-cloth
  2. Run pip install -r requirements.txt to install dependencies.

  3. Run python setup.py install. This should automatically "cythonize" the Python .pyx files. An alternative is to do python setup.py develop in development mode. This has the advantage in that code changes in package-dependent files will automatically be updated when you run code, and you avoid having to "re-install" the package. However, since we use Cython code in files that end with .pyx, those have to be re-compiled each time we run the code. Thus, they automatically require another python setup.py call anyway, so it seems like the distinction between install mode and develop mode doesn't matter here. For example, if running a script, I usually do this each time I run code:

    python setup.py install ; python examples/<script_name>.py

    So far this setup is working fine for us.

For quick testing, try running the policies using the provided examples/analytic.py script. This is the main script that we use to generate demonstration data for experiments. For example, this should work right away:

python examples/analytic.py oracle --max_episodes=400 --seed=1336 --tier=1

To actually visualize the renderer, you need to install it, and change the appropriate config file in cfg/ so that the render_opengl setting is True.

Renderer Installation

These instructions have been tested on Mac OS X and Ubuntu 18.04. For some reason, we have not been able to get this working for Ubuntu 16.04. For Ubuntu 18.04, you might need sudo access for make -j4 install. Currently the simulation is rendered in an independent C++ program. To set up the renderer,

  1. Navigate to render/ext/libzmq. Run

    mkdir build; cd build
    cmake ..
    make -j4 install
  2. Navigate to render/ext/cppzmq. Again run

    mkdir build; cd build
    cmake ..
    make -j4 install

(Edit: this step seems to not be necessary, see December 2020 comment below.)

  1. Navigate to render. Run
    mkdir build; cd build
    cmake ..
    make

Finally you should have an executable clothsim in render/build. To test that it is working, go to render/build and run ./clothsim on the command line. You should see an empty window appear. There should be no segmentation faults. Occasionally I have seen it fail on installed machines, but normally rebooting fixes it.

Notes:

Citation

If you find the code or other related resources useful, please consider citing the paper:

@inproceedings{seita_fabrics_2020,
    author = {Daniel Seita and Aditya Ganapathi and Ryan Hoque and Minho Hwang and Edward Cen and Ajay Kumar Tanwani and Ashwin Balakrishna and Brijen Thananjeyan and Jeffrey Ichnowski and Nawid Jamali and Katsu Yamane and Soshi Iba and John Canny and Ken Goldberg},
    title = {{Deep Imitation Learning of Sequential Fabric Smoothing From an Algorithmic Supervisor}},
    booktitle = {IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)},
    Year = {2020}
}