Skip to main content
Donkeycar provides templates - pre-configured vehicle applications that assemble parts for common use cases. Templates are Python scripts that you customize for your specific car configuration.

What are Templates?

Templates are complete working applications located in donkeycar/templates/. Each template:
  • Assembles parts into a functional vehicle
  • Configures the drive loop
  • Provides command-line interfaces
  • Includes configuration options
  • Serves as examples for building custom vehicles

Available Templates

1. Complete Template (complete.py)

Purpose: Full-featured autonomous car with machine learning autopilot Location: donkeycar/templates/complete.py Features:
  • Camera input (multiple types supported)
  • Web and joystick control
  • ML model inference (Keras, PyTorch, TensorFlow Lite)
  • Data recording (TubWriter)
  • Autopilot mode with model hot-reloading
  • Drivetrain control (servo, ESC, differential drive)
  • Optional sensors (IMU, LIDAR, odometry, GPS)
  • LED status indicators
  • Simulator support (Donkey Gym)
  • Telemetry publishing
  • FPV video streaming
Usage:
Key Parts: From complete.py:50-576:
Configuration (cfg_complete.py):
The complete template is the most commonly used. It includes everything you need for collecting training data and running an autopilot.

2. Basic Template (basic.py)

Purpose: Minimal car for manual driving and data collection Location: donkeycar/templates/basic.py Features:
  • Camera input
  • Web or joystick control
  • Simple data recording
  • Optional autopilot
  • Minimal dependencies
Usage:
Key Parts: From basic.py:51-204:
When to use: Starting a new project, learning Donkeycar, or need minimal setup

3. Path Follow Template (path_follow.py)

Purpose: Follow a recorded path using odometry or GPS Location: donkeycar/templates/path_follow.py Features:
  • Path recording and playback
  • Cross-track error (CTE) calculation
  • PID steering control
  • Odometry/pose estimation (wheel encoders)
  • Optional Intel RealSense T265 tracking
  • Optional GPS positioning
  • Path visualization
  • Save/load/reset paths via buttons
Usage:
Key Parts: From path_follow.py:74-442:
Configuration (cfg_path_follow.py):
Workflow:
  1. Drive manually to record a path
  2. Press save button to save path
  3. Reset car to start position
  4. Switch to autopilot mode
  5. Car follows recorded path using PID control
Path following is ideal for repeated laps on a track or warehouse navigation without requiring machine learning training.

4. Computer Vision Control (cv_control.py)

Purpose: Drive using computer vision (line following, object detection) Location: donkeycar/templates/cv_control.py Features:
  • Real-time computer vision processing
  • PID-based steering control
  • Configurable CV algorithm (plug in your own)
  • No ML training required
  • Live image overlay showing detection
Usage:
Key Parts: From cv_control.py:37-260:
Configuration (cfg_cv_control.py):
Example CV Controller (line follower):
When to use: Line following, cone detection, or any vision-based task that doesn’t need ML

5. Simulator Template (simulator.py)

Purpose: Run in Donkey Gym simulator Location: donkeycar/templates/simulator.py Features:
  • Connects to Donkey Gym simulator
  • Same API as physical car
  • Records simulated sensor data
  • Test models in simulation
  • Includes brake control
  • Optional sensor recording (lidar, IMU, velocity)
Usage:
Key Parts: From simulator.py:36-423:
Configuration (cfg_simulator.py):
The simulator template allows you to develop and test without physical hardware. Models trained in simulation can be transferred to real cars, though performance may vary.

Template Selection Guide

Common Template Structure

All templates follow a similar pattern:

Customizing Templates

1. Copy Template to Your Project

This creates manage.py based on the complete template.

2. Modify manage.py

Add custom parts:

3. Adjust Configuration

Edit myconfig.py:

Helper Functions

Templates use helper functions for common setup:

add_camera()

From complete.py:832-901:

add_user_controller()

From complete.py:687-760:

add_drivetrain()

From complete.py:942-1148:

Creating Your Own Template

Best Practices

  1. Start with existing template: Modify rather than create from scratch
  2. Use helper functions: Reuse add_camera(), add_drivetrain(), etc.
  3. Keep configuration in myconfig.py: Don’t hardcode values
  4. Document changes: Add comments explaining modifications
  5. Test incrementally: Add one part at a time and test
  6. Version control: Track changes to manage.py

Next Steps

  • Learn about the Architecture that templates build on
  • Understand the Vehicle Loop that runs templates
  • Study Parts to create custom components
  • Explore the Memory system for data flow