IMU (Inertial Measurement Unit)
Measures acceleration, rotation, and orientation. Location:donkeycar/parts/imu.py:9
Supported Sensors
- MPU6050: 6-axis (accelerometer + gyroscope)
- MPU9250: 9-axis (accelerometer + gyroscope + magnetometer)
- Accelerometer (m/s²): Linear acceleration on X, Y, Z axes
- Gyroscope (rad/s): Angular velocity on X, Y, Z axes
- Temperature (°C): Die temperature
- Magnetometer (MPU9250 only, μT): Magnetic field on X, Y, Z axes
GPS
Global positioning from NMEA-compatible GPS modules. Location:donkeycar/parts/gps.py
GpsNmeaPositions
Converts NMEA sentences to UTM coordinates.- List of (timestamp, x, y) tuples
- x, y in UTM coordinates (meters)
GpsPosition
Combined GPS reader that returns the latest position. Location:donkeycar/parts/gps.py:54
- Latitude/Longitude in degrees
- Converted to UTM (x, y) in meters
- Timestamp from sentence
Encoders
Measure wheel rotation for odometry and velocity. Note: The encoder.py module is deprecated. Usetachometer.py and odometer.py instead.
Rotary Encoder (Legacy)
Location:donkeycar/parts/encoder.py:128
GPIO-based rotary encoder (deprecated in favor of donkeycar.parts.tachometer.Tachometer).
- Measure wheel circumference (C) in mm
- Count encoder ticks per revolution (T)
- Set
mm_per_tick = C / T
- velocity (m/s): Current speed
- distance (m): Total distance traveled
Tachometer (Modern)
For current speed measurement, use:Odometer (Modern)
For distance measurement:Ultrasonic Sensors
For obstacle detection and distance measurement. Location: Custom implementation neededLIDAR
For 2D/3D environment scanning. Location:donkeycar/parts/lidar.py (if available)
Configuration
Inmyconfig.py:
Data Recording
Add sensor outputs to TubWriter:Using Sensor Data in Models
For IMU-augmented models:Common Issues
IMU Not Detected
GPS No Fix
- Ensure antenna has clear view of sky
- Wait 30-60 seconds for initial fix (cold start)
- Check NMEA output:
cat /dev/ttyUSB0 - Verify GPS LED is blinking
Encoder Not Counting
- Check GPIO pin connections
- Verify pigpio daemon is running:
sudo systemctl status pigpiod - Test with multimeter or oscilloscope
- Check for proper pull-up/pull-down resistors
Serial Port Permission Denied
Next Steps
- Keras Models - Use sensor data in AI models
- Data Stores - Record sensor data
- Custom Parts - Create custom sensors
