(Optional) Simulator Setup

Donkeycar also has a simulated environment available if real-world resources are unavailable to you.

This page is for those who wish to complete this project, but do not have access to a physical car and raspberry pi. Below, you will find the steps to set up the Donkeycar simulator on your own computer. After the simulator is set up and you are able to drive around the virtual environment and collect data, you can skip to Collecting Data to complete the rest of the project. From this point on, treat your own computer where you run the simulation as if it is the raspberry pi in the rest of the instructions. This means that if the instructions say to run a command on the Pi, run it on your own computer. You should still have access to a regular Chameleon instance if you want to train your model in a reasonable time. To reserve your Chameleon instance, go to Reserving your Pi on Chi@Edge, click the link to the Trovi artifact, and only run the reserve_baremetal script, not the one to reserve the Pi. Setting up the simulator is also needed for an extension of this project: reinforcement learning.

Simulator Set-up and Configuration

  1. Create a directory in the root called projects

mkdir ~/projects

Note: make sure you have python installed

  1. Inside of this directory, clone the donkeycar repository

cd ~/projects
git clone https://github.com/autorope/donkeycar.git

Note: this should create a donkeycar directory inside of the projects directory

  1. Change to donkeycar directory and set it up

cd donkeycar
git checkout main

Installation for Linux and Windows

pip install -e [pc]

Installation for Mac

pip install -e .\[pc\]
  1. Download and unzip the simulator for the host pc

    1. Go to the latest release and click the zip file for your operating system

    2. Unzip the contents

    3. Remember the location and find the absolute file path of the executable file

Note: on Mac, it will download a zip, unzip it and inside of the file is a .app file, two-finger click it and click “Show Package Contents”

  1. Set aside the path which should look akin to: “/Users/kylezheng/Downloads/DonkeySimMac/donkey_sim.app/Contents/MacOS/donkey_sim”

  2. Clone the donkeycar gym repo in projects and set it up

cd ~/projects
git clone https://github.com/tawnkramer/gym-donkeycar.git
cd gym-donkeycar

Note: creates gym-donkeycar directory inside of the projects directory

Installation for Windows and Linux:

pip install -e .[gym-donkeycar]

Installation for Mac:

pip install -e .\[gym-donkeycar\]
  1. Creating donkey application

cd ~/projects
donkey createcar --path mycar
cd mycar
  1. File configuration for Donkeycar gym and Simulator

nano myconfig.py

Use this keyboard shortcut: control + w. Type “gym” and press enter.

Find the area that reads:

DONKEY_GYM = False
DONKEY_SIM_PATH = “path to sim”
DONKEY_GYM_ENV_NAME = “donkey-generated-track-v0”

Uncomment all three lines by deleting the # at the beginning of the lines

Change the lines to read:

DONKEY_GYM = False
DONKEY_SIM_PATH = <path_to_executeable>
DONKEY_GYM_ENV_NAME = “donkey-generated-track-v0”

Inside of the <> is the absolute file path for the executable set aside in Step 5

  1. Run the Simulator

python manage.py drive

In a moment, this will open a window with a car in simulated surroundings

Note: You can not control the car from this window

Open Google Chrome and type this url in:

http://localhost:8887

With Joystick mode on, our through a physical game controller, you can control the car, which should propagate from through both the WebUI and the Simulator Opened

Note: Throttle can be changed from 100% to a lower number, preferably 10%

  1. Configuration

    1. Go to the envs directory:

    2. Example file path:

cd /Users/kylezheng/projects/gym-donkeycar/gym_donkeycar/envs

Inside of donkey_env.py change steer_limit to 0.5

Reinforcement learning can be found in donkey_sim.py

Other lower priority configurations can be changed from the same files

Note: Do not attempt to use the simulator trained model in the real world! Remember the Simulator to Real Gap. Although there is a technique utilizing auto-encoders and Soft Actor Critic that allow for robust performance, documentation has not been included (yet).

Last updated