Home

Awesome

OpenAI Gym Environments for Donkey Car

pypi CI Documentation Status

Donkey Car OpenAI Gym

Installation

Download simulator binaries: https://github.com/tawnkramer/gym-donkeycar/releases

Install master version of gym donkey car:

pip install git+https://github.com/tawnkramer/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

# SET UP ENVIRONMENT
# You can also launch the simulator separately
# in that case, you don't need to pass a `conf` object
exe_path = f"{PATH_TO_APP}/donkey_sim.exe"
port = 9091

conf = { "exe_path" : exe_path, "port" : port }

env = gym.make("donkey-generated-track-v0", conf=conf)

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

# Exit the scene
env.close()

or if you already launched the simulator:

import gym
import numpy as np

import gym_donkeycar

env = gym.make("donkey-warren-track-v0")

obs = env.reset()
try:
    for _ in range(100):
        # drive straight with small speed
        action = np.array([0.0, 0.5])  
        # execute the action
        obs, reward, done, info = env.step(action)
except KeyboardInterrupt:
    # You can kill the program using ctrl+c
    pass

    # Exit the scene
env.close()

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:

Example info:

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

Environments

Codestyle

We are using black codestyle (max line length of 127 characters) together with isort to sort the imports.

Please run make format to reformat your code. You can check the codestyle using make check-codestyle and make lint.

Tests

Type checking with pytype:

make type

Codestyle check with black, isort and flake8:

make check-codestyle
make lint

To run pytype, format and lint in one command:

make commit-checks

Build the documentation:

make docs

Credits

Original Source Code

Tawn Kramer - https://github.com/tawnkramer/gym-donkeycar

Roma Sokolkov - https://github.com/r7vme/gym-donkeycar cloned with permission from https://github.com/tawnkramer/sdsandbox

Maintainer

Maxime Ellerbach - https://github.com/Maximellerbach/gym-donkeycar

Release Engineer Leigh Johnson: https://github.com/leigh-johnson

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