raisimGym is an example of a gym environment using raisim. It uses stable-baselines (https://github.com/hill-a/stable-baselines) for training and pybind11 (https://github.com/pybind/pybind11) for wrapping raisim in python.
- Linux only. support ubuntu 16.04 and 18.04 but might work on other distributions
- g++, gcc > 6 (how to install?)
- cmake > 3.10 (how to install?)
Please install/save everything locally to prevent corrupting your system files. We will assume that you have a single workspace where you save all repos related to raisim.
Here we introduce two variables
- WORKSPACE: workspace where you clone your git repos
- LOCAL_BUILD: build directory where you install exported cmake libraries
You can check out our docker file if you are stuck.
- Install python3
- For Ubuntu18.04 (sudo apt-get install -y cmake python3.6-dev python3-pip libpython3.6-dev)
- For Ubuntu16.04 (sudo apt-get install -y cmake python3.5-dev python3-pip libpython3.5-dev)
- Setup your python environment (virtualenv or conda) with Python > 3.5
Install the following dependencies
- Raisim (https://github.com/leggedrobotics/raisimLib)
- RaisimOgre (https://github.com/leggedrobotics/raisimOgre)
- yaml-cpp (sudo apt-get install libyaml-cpp-dev)
Now install pybind11 as following
cd $WORKSPACE
git clone https://github.com/pybind/pybind11.git
cd pybind11 && git checkout v2.2.4 && mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$LOCAL_BUILD -DPYBIND11_TEST=OFF
make install -j4
You might have to add LOCAL_BUILD/lib to your $LD_LIBRARY_PATH to ensure that ld finds Ogre3D shared objects.
- Compile your c++ environment (instructions followed)
- Run your learning script (instructions followed)
or use the dockerfile provided (instruction below)
Set your compiler to g++>6.0 as following
export CXX=/usr/bin/g++-8 && export CC=/usr/bin/gcc-8
Now compile raisimGym as
python3 setup.py install --CMAKE_PREFIX_PATH LOCAL_BUILD --env /WHERE/YOUR/CUSTOM/ENVIRONMENT/IS
The "--env" directory should include a file called "Environment.hpp" which contains ENVIRONMENT class.
For the ANYmal example,
python3 setup.py install --CMAKE_PREFIX_PATH $LOCAL_BUILD --env anymal
For the Laikago example,
python3 setup.py install --CMAKE_PREFIX_PATH $LOCAL_BUILD --env laikago
You can make your own runner. To use the example runner,
python3 scripts/anymal_blind_locomotion.py
- Install docker and Nvidia-docker2 (instruction).
- Build an image
docker build -t raisim_gym $WORKSPACE/raisimGym/dockers/gpu
- Create a container using the provided docker runner
$WORKSPACE/raisimGym/dockers/gpu/runner.bash
- Inside the container, compile your environment and execute your runner
- Trained with RTX 2080 + Intel 8700K + PPO [1]
- 18 dof quadrupedal robot, 34-dimentional observation space
Initial policy | 38 seconds of training |
---|---|
![]() |
![]() |
76 seconds of training | 112 seconds of training |
---|---|
![]() |
![]() |
- Due to conversion between numpy and eigen, the interface class (e.g., VectorizedEnv) should use row major matrices only.
- When build fails, try again after deleting the
build
folder
raisimGym is meant to be a minimal example. Please do not submit a pull request that contains features targeting specific applications. Bug fix/code clean-up are welcome.
Fork the repo, make changes and then send a pull request. Instructions can be found here
[1] Schulman, John, et al. "Proximal policy optimization algorithms." arXiv preprint arXiv:1707.06347 (2017).