reinmav-gym
is a gym environment for developing mav controllers using the openai gym framework. The environment composes of two environments: native
which has a built in simulator and mujoco
which uses the mujoco simulator.
native
environment has a built in dynamics 2D / 3D model that does not require any additional physics engine.mujoco
environment has a quadrotor model in the mujoco simulator for more complex environments
- python3.6 (or 3.7) environment by one of the following
- system python
- conda
- virtualenv
- venv
- gym
- vpython
- baselines SOURCE BUILD from 90d66776a49ad5e732b935dfc891bfbd06035ed2
- matplotlib
-
the code was tested on Ubuntu 16.04, 18.04 and macOS; but matplotlib has some issues in macOS. Please see this doc for more details: we strongly recommend to use conda + pythonw (
conda install python.app
) on macOS. -
pip package version of baselines has some issue. Please build from the source (commit code: 90d66776a49ad5e732b935dfc891bfbd06035ed2)
- Install package dependencies
$ sudo apt update && sudo apt install libopenmpi-dev
- Install gym. The installation guidelines can be found here
$ pip install gym
- Install pip dependencies by
$ pip install -r requirements.txt
- [Optional] Install mujoco, mujoco-py and gym[all]
- See For mujoco env (optional) for more details
- [Optional] Install the baseline repository to use baseline algorithms to train the models
sudo apt-get update && sudo apt-get install cmake libopenmpi-dev python3-dev zlib1g-dev
git clone https://github.com/openai/baselines.git
cd baselines
pip install tensorflow-gpu # if you have a CUDA-compatible gpu and proper drivers
pip install -e .
- Clone the package and cd into it
git clone https://github.com/ethz-asl/reinmav-gym.git
cd reinmav-gym
- The environment is tested on python 3.6. Make sure you have the right python version when installing the environment
pip install -e .
You can check your installation using $ pip show
pip show gym-reinmav
Name: gym-reinmav
Version: 0.0.1
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Location: /Users/YOUR_INSTALLED_PATH/openai/venv/lib/python3.6/site-packages
Requires: gym
Required-by:
A simple geometric controller is implemented to see if the quadrotor can fly properly.
$ cd reinmav-gym/test
$ python test_quadrotor2d.py
or
$ python test_quadrotor3d.py
- download mjpro150 from MuJoCo website
- put mjpro150 directory into ~/.mujoco
- put mjkey.txt into ~/.mujoco
- install apt dependencies
- for example on Ubuntu 16.04:
$ apt-get install -y python-pyglet python3-opengl zlib1g-dev libjpeg-dev patchelf \ cmake swig libboost-all-dev libsdl2-dev libosmesa6-dev xvfb ffmpeg
- see gym README - Installing everything section for more details.
- export LD_LIBRARY_PATH
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/.mujoco/mjpro150/bin
$ # check your nvidia driver version
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia-<YOUR VERSION>
- install gym by
$ pip3 install 'gym[all]'
Note. mujoco200 (MuJoCo 2.0) is not supported yet.
The environment can be used as anyother gym environments. This can be done by doing the following in your script
import gym
...
env = gym.make('quadrotor3d-v0').unwrapped
quadrotor3d-v0
is the environment ID that is registered in the gym environment. The list of environment ids in this repo can be found in `gym_reinmav/init.py' file.
The environment can be also be tested using the openai baselines package, for example as the following.
python -m gym_reinmav.run --alg=ppo2 --env=quadrotor2d-v0 --network=mlp --play
For basic usages on baslines
, refer to this repo