Config class manages configuration for your Donkeycar. It loads settings from Python files (config.py and myconfig.py) and makes them available as attributes.
Overview
Donkeycar uses a two-file configuration system:- config.py - Default settings that come with Donkeycar templates
- myconfig.py - Your personal overrides that take precedence
Loading Configuration
load_config(config_path=None, myconfig="myconfig.py")
The primary function to load configuration.
str
default:"None"
Path to config.py file. If None, searches for config.py in the current working directory.
str
default:"myconfig.py"
Filename of personal config overrides. Looked for in the same directory as config.py.
Config
Config instance with all settings loaded as attributes
Config Class
from_pyfile(filename)
Load configuration from a Python file.
str
required
Path to the Python file containing configuration variables
bool
True if file was loaded successfully
Only variables in UPPER_CASE are loaded from the file. This convention separates configuration from code.
from_object(obj)
Load configuration from a Python object (module, class, etc).
object
required
Object containing configuration attributes
from_dict(d, keys=[])
Update configuration from a dictionary.
dict
required
Dictionary of configuration key-value pairs
list
default:"[]"
Optional list of keys to update. If empty, all UPPER_CASE keys are updated.
show()
Print all configuration values to console.
__str__()
Get configuration as a string (list of tuples).
to_pyfile(path)
Save current configuration to a Python file.
str
required
Path where the configuration file should be written
Configuration System
config.py vs myconfig.py
The two-file system separates defaults from customization: config.py (template defaults)Common Configuration Options
Camera Settings
Drive Train Settings
Vehicle Loop Settings
Joystick/Controller Settings
Training Settings
Recording Settings
AI/Autopilot Settings
Usage Examples
Example: Basic Drive Script
Example: Environment-Specific Configs
Example: Runtime Overrides
Example: Config Validation
Best Practices
Keep myconfig.py Minimal
Only override what you need to change:Document Your Overrides
Add comments explaining why you changed values:Version Control
Track myconfig.py in git to preserve your settings:Backup Before Updates
Before updating Donkeycar:See Also
- Vehicle - Using config in the vehicle
- Create Car - Initial configuration
- Calibrate - Calibrating PWM values
- Training - Training configuration options
