Skip to main content
The Donkey Gym simulator allows you to train and test your autonomous models in virtual environments without risking your physical car. Built on Unity and OpenAI Gym, it provides realistic physics and multiple track environments.

Overview

Donkey Gym enables:
  • Virtual racing on generated tracks and real-world courses
  • Safe training without hardware wear
  • Rapid iteration with instant resets
  • Latency simulation to test real-world conditions
  • Multi-environment support including warehouse and AVC tracks

Installation

Download the simulator binary for your platform:
Install the Python gym environment:

Configuration

Edit your myconfig.py to enable the simulator:

DonkeyGymEnv Part

The DonkeyGymEnv part connects your vehicle to the simulator:
From donkeycar/parts/dgym.py:67-71:

Recording Telemetry

Capture additional telemetry from the simulator:
When enabled, the simulator outputs include:

Latency Simulation

The simulator supports artificial latency to test control algorithms under realistic network conditions:
The delay buffer implementation from donkeycar/parts/dgym.py:47-62:

Running the Simulator

Local Mode

Start your car in simulator mode:
The simulator will launch automatically and connect.

Remote Mode

Start the simulator manually, then connect:

Training

Train models using simulator data:

Virtual Race League

Race against others online:
Configure your racer profile:

Resource Management

The simulator uses GPU resources. To avoid conflicts:
From donkeycar/templates/simulator.py:47-50.

Troubleshooting

Connection Issues

Performance

  • Lower image resolution in GYM_CONF
  • Disable unnecessary telemetry recording
  • Close other GPU-intensive applications

Path Not Found

Best Practices

  1. Start with generated tracks - Test algorithms on varied terrain
  2. Use artificial latency - Prepare for real-world network delays
  3. Record telemetry - Analyze car behavior and track position
  4. Transfer learning - Fine-tune simulator models with real-world data
  5. Test edge cases - Use simulator to safely test failure scenarios

Next Steps