donkey calibrate command provides an interactive tool for calibrating your car’s servo motors and electronic speed controller (ESC). Proper calibration is essential for accurate steering and throttle control.
Usage
PWM Controllers
Donkeycar supports multiple PWM controller types:- PCA9685: I2C PWM controller (most common, used with Raspberry Pi)
- Arduino: Arduino board with Firmata firmware
- Custom PWM pins: Direct GPIO PWM pins (RPI_GPIO, etc.)
Options
PCA9685 Options (Default)
The PCA9685 channel number to calibrate (0-15). Typically:
- Channel 0: Steering servo
- Channel 1: Throttle ESC
The I2C address of the PCA9685 controller. Default is
0x40.The I2C bus number. If not specified, it will be auto-detected.
The PWM frequency in Hz. Default is 60 Hz, which is standard for servos.
Arduino Options
Use Arduino pin for PWM output. When enabled, the
--channel parameter specifies the Arduino pin number.Custom PWM Pin Options
Specify a custom PWM pin using pin specifier syntax:
RPI_GPIO.BOARD.33: Raspberry Pi GPIO pin 33 (BOARD numbering)PCA9685.1:40.13: PCA9685 at address 0x40, channel 13
Calibration Process
Step 1: Identify Your Hardware
Before calibrating, identify:- Which channel your servo/ESC is connected to
- The I2C address of your PCA9685 (if applicable)
- Your hardware’s safe PWM range (typically 250-450)
Step 2: Start Calibration
For steering servo on channel 0:Step 3: Test PWM Values
The calibration tool will prompt you to enter PWM values:- Lower values (e.g., 250-300): Turn servo left or move backward
- Middle values (e.g., 370): Center position or stopped
- Higher values (e.g., 400-450): Turn servo right or move forward
Step 4: Record Your Values
Note the PWM values for:- Steering: Left max, center, right max
- Throttle: Full reverse, stopped, full forward
Step 5: Update Configuration
Add the calibrated values to yourmyconfig.py:
Examples
Calibrate steering servo (PCA9685 channel 0)
Calibrate throttle ESC (PCA9685 channel 1)
Use custom I2C address
Calibrate with specific I2C bus
Use custom PWM frequency
Calibrate Arduino pin
Calibrate custom PWM pin
Safety Tips
Troubleshooting
Servo doesn’t move
- Verify the channel number is correct
- Check physical connections to the PCA9685
- Ensure the PCA9685 has external power connected
- Try different PWM values (some servos respond to different ranges)
“No such file or directory” error
- Ensure I2C is enabled on your Raspberry Pi:
sudo raspi-config - Install I2C tools:
sudo apt-get install i2c-tools - Verify PCA9685 is detected:
i2cdetect -y 1
Servo jitters or buzzes
- You may be at the limit of the servo’s range
- Reduce the PWM value to a more conservative setting
- Check that external power supply provides sufficient current
Arduino not found
- Verify Arduino has Firmata firmware installed
- Check USB connection and permissions
- Install pyFirmata:
pip install pyFirmata
Next Steps
After calibration:- Update your
myconfig.pywith the calibrated values - Test your car with
python manage.py drive - Verify steering and throttle respond correctly
- Collect training data by driving manually
- Train your first model with
donkey train
