Skip to content

DocGarbanzo/donkeycar

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4,310 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Donkeycar: a python self driving library

Build Status Lint Status Release

All Contributors Issues Pull Requests Forks Stars License

Discord

Donkeycar is minimalist and modular self driving library for Python. It is developed for hobbyists and students with a focus on allowing fast experimentation and easy community contributions.

Quick Links

donkeycar

Use Donkey if you want to:

  • Make an RC car drive its self.
  • Compete in self driving races like DIY Robocars
  • Experiment with autopilots, mapping computer vision and neural networks.
  • Log sensor data. (images, user inputs, sensor readings)
  • Drive your car via a web or game controller or RC controller.
  • Leverage community contributed driving data.
  • Use existing CAD models for design upgrades.

Get driving.

After building a Donkey2 you can turn on your car and go to http://localhost:8887 to drive.

Modify your cars behavior.

The donkey car is controlled by running a sequence of events

#Define a vehicle to take and record pictures 10 times per second.

import time
from donkeycar import Vehicle
from donkeycar.parts.cv import CvCam
from donkeycar.parts.tub_v2 import TubWriter
V = Vehicle()

IMAGE_W = 160
IMAGE_H = 120
IMAGE_DEPTH = 3

#Add a camera part
cam = CvCam(image_w=IMAGE_W, image_h=IMAGE_H, image_d=IMAGE_DEPTH)
V.add(cam, outputs=['image'], threaded=True)

#warmup camera
while cam.run() is None:
    time.sleep(1)

#add tub part to record images
tub = TubWriter(path='./dat', inputs=['image'], types=['image_array'])
V.add(tub, inputs=['image'], outputs=['num_records'])

#start the drive loop at 10 Hz
V.start(rate_hz=10)

Installation

Donkeycar uses uv for environment management. Install uv first:

curl -LsSf https://astral.sh/uv/install.sh | sh

Then create a persistent virtual environment and activate it on login by adding the source line to your shell profile.

Raspberry Pi

Camera support (picamera2, libcamera) requires system packages that are not on PyPI. Install them first:

sudo apt install python3-libcamera python3-picamera2

Then create the venv using the system Python (3.13 on Raspberry Pi OS Trixie) with --system-site-packages so the venv can see the camera libraries:

uv venv ~/env --python 3.13 --system-site-packages
echo 'source ~/env/bin/activate' >> ~/.zshrc
source ~/env/bin/activate

User install (from PyPI):

uv pip install donkeycar[pi]

Developer install (from a git clone):

uv pip install -e ".[pi,dev]"

Mac

uv venv ~/.venvs/donkeycar --python 3.12
echo 'source ~/.venvs/donkeycar/bin/activate' >> ~/.zshrc
source ~/.venvs/donkeycar/bin/activate

User install (from PyPI):

uv pip install donkeycar[macos]

Developer install (from a git clone):

uv pip install -e ".[macos,dev]"

PC (Linux/Windows)

uv venv ~/.venvs/donkeycar --python 3.12
echo 'source ~/.venvs/donkeycar/bin/activate' >> ~/.zshrc
source ~/.venvs/donkeycar/bin/activate

User install (from PyPI):

uv pip install donkeycar[pc]

Developer install (from a git clone):

uv pip install -e ".[pc,dev]"

Once the venv is activated in your shell profile the donkey command is available from any directory without needing uv run.

See home page, docs or join the Discord server to learn more.

About

Open source hardware and software platform to build a small scale self driving car.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Jupyter Notebook 75.3%
  • Python 22.0%
  • JavaScript 1.4%
  • HTML 0.6%
  • kvlang 0.4%
  • C++ 0.2%
  • Other 0.1%