Home

Awesome

dm_control2gym

dm_control2gym is a small wrapper to make DeepMind Control Suite environments available for OpenAI Gym.

Installation

$ git clone https://github.com/martinseilair/dm_control2gym/
$ cd dm_control2gym
$ pip install .

Tested with Python 3.5.2 and Ubuntu 16.04.

Quick start

import gym
import dm_control2gym

# make the dm_control environment
env = dm_control2gym.make(domain_name="cartpole", task_name="balance")

# use same syntax as in gym
env.reset()
for t in range(1000):
    observation, reward, done, info = env.step(env.action_space.sample()) # take a random action
    env.render()

Short documentation

Spaces and Specs

The dm_control specs are converted to spaces. If there is only one entity in the observation dict, the original shape is used for the corresponding space. Otherwise, the observations are vectorized and concatenated. Note, that the pixel observation is processed separately through the render routine.

The difference between the Discrete and the corresponding ArraySpec with type np.int, is that the domain ArraySpec is arbitrary and of that the domain of Discrete always starts at 0. Therefore, the domain is shifted to obtain a valid Discrete space.

Rendering

Three rendering modes are available by default:

You can create your own rendering modes before making the environment by:

dm_control2gym.create_render_mode(name, show=True, return_pixel=False, height=240, width=320, camera_id=-1, overlays=(),
             depth=False, scene_option=None)

It is possible to render in different render modes subsequently. Output of several render modes can be visualized at the same time.

Procedurally generated environments

Example

env = dm_control2gym.make(domain_name="cartpole", task_name="k_poles",task_kwargs={'k':10})

What's new

2018-01-25: Optimized registering process (thanks to rejuvyesh), added access to procedurally generated environments, added render mode functionality