Giter Club home page Giter Club logo

donkey_rl's Introduction

Train Donkey Car in Unity Simulator with Reinforcement Learning

Donkey Car is an open source DIY self driving platform for small scale RC cars. This repo includes implementation of a Donkey Car simulator that is reinforcement learning friendly. You can interact with the Donkey environment using the familiar OpenAI gym like interface. The code was modified from Tawn Kramer sdsandbox repo.

As a simple demo, I've implemented Double Deep Q Learning (DDQN) and used it to train Donkey car to drive itself in the simulator. The below screencast shows the trained Donkey car (after ~100 episodes) in action.

My goal is to use reinforcement learning to train Donkey Car to compete in a real car race. This involved having the Donkey car trained in simulation first and transfer the learned policy to the real world.

For more information about this project, please check out my blog post at https://flyyufelix.github.io/2018/09/11/donkey-rl-simulation.html.

Usage

Download Donkey Unity Environment

The Donkey Car simulator is created with Unity. There are 3 Unity scenes available (created by Tawn Kramer) for training now, which are generated roads, warehouse, and Sparkfun AVC. Before we run the RL training script, we have to either build the Donkey Car Unity environment ourselves (need to install Unity) or download the pre-built environment executables below:

Linux: donkey.x86_64 | MacOS: donkey.app

Then place the executable inside the donkey_rl/src folder.

Alternatively, if you wish to build the Donkey Unity environment yourself. You need to first download Unity. You can find the Donkey Unity project at donkey_rl/sdsim.

Notice that I do have the Windows executable available for download. If you are Windows users, please go ahead and build the environment yourself.

Train Donkey car with Reinforcement Learning

First, we have to install donkey_gym python package, which extends the OpenAI gym class to allow RL developers to interact with Donkey environment using the familiar OpenAI gym like interface.

To install the package, navigate to donkey_rl/src/donkey_gym folder and type the follow command:

$ cd donkey_rl/src/donkey_gym
$ pip install -e .

After installing donkey_gym, we can go ahead to test the environment by running the DDQN script that I've implemented:

$ cd donkey_rl/src
$ python ddqn.py

If the script runs successfully, you should see some printouts in the command prompt with the training statistics (e.g. episode number, action, reward, etc).

Notice that by default a Unity GUI will be launched where you can see the Donkey car being trained. If you want to train in headless mode (i.e. no GUI), you can edit donkey_rl/src/donkey_gym/donkey_gym/envs/donkey_env.pyand set headless flag to True.

Dependencies

donkey_rl's People

Contributors

flyyufelix avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.