Skip to content
OpenAI gym environment for donkeycar simulator
Python Makefile
Branch: master
Clone or download
Latest commit 3c33a9e Aug 13, 2019


OpenAI Gym Environments for Donkey Car

Documentation Status

Donkey Car OpenAI Gym


  • Install with pip
pip install gym-donkeycar

Example Usage

A short and compact introduction for people who know gym environments, but want to understand this one. Simple example code:

import os
import gym
import gym_donkeycar
import numpy as np

os.environ['DONKEY_SIM_PATH'] = f"{PATH_TO_APP}/"
os.environ['DONKEY_SIM_PORT'] = str(9091)
os.environ['DONKEY_SIM_HEADLESS'] = str(0) # "1" is headless

env = gym.make("donkey-warehouse-v0")

#%% PLAY
obv = env.reset()
for t in range(100):
    action = np.array([0.0,0.5]) # drive straight with small speed
# execute the action
obv, reward, done, info = env.step(action)

Action space

A permissable action is a numpy array of length two with first steering and throttle, respectively. E.g. np.array([0,1]) goes straight at full speed, np.array([-5,1]) turns left etc.

Action Space: Box(2,)

Action names: ['steer', 'throttle']

What you receive back on step

  • obv: The image that the donkey is seeing (np.array shape (120,160,3))
  • reward: a reward that combines game over, how far from center and speed (max=1, min approx -2)
  • done: Boolean. Game over if cte > max_cte or hit != "none"
  • info contains: - cte: Cross track error (how far from center line) - positions: x,y,z - speed: positive forward, negative backward - hit: 'none' if all is good.

example info:

{'pos': (51.49209, 0.7399381, 117.3004),
 'cte': -5.865292,
 'speed': 9.319956,
 'hit': 'none'}


  • "donkey-warehouse-v0"
  • "donkey-generated-roads-v0"
  • "donkey-avc-sparkfun-v0"
  • "donkey-generated-track-v0"


Original Source Code

Tawn Kramer -

Roma Sokolkov - cloned with permission from

Release Engineer

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

You can’t perform that action at this time.