Building your DeepPiCar
I. Bill of Materials
- For this project you will need the following materials
| Component | Link | Price (USD) |
|---|---|---|
| Male to Female Jumper | Link | $7 |
| MicroSD Card (32 GB) | Link | $7 |
| New Bright 1:24 Scale RC Car | Link | $20 |
| Pololu DRV8835 Motor Driver | Link | $15 |
| Pololu Power Cable | Link | $2 |
| Power Bank | Link | $17 |
| Raspberry Pi Zero 2 W | Link | $25 |
| Raspberry Pi Zero Camera v1.3 | Link | $7 |
| USB Micro to USB | Link | $7 |
| Total | $107 |
- Additionally, you will need to 3D print these CAD models to mount the hardware to the car.
- Main hardware mount
- Thread plate (NOTE: This thread plate is designed for m2.5 screws. Feel free to create other plates if you wish to use different screw types.)
- Camera mount
- Camera cover
II. Construction
III. Software Setup
The DeepPicar repository is built and tested on the Raspberry Pi OS (Legacy) Bullseye. You can flash your Raspberry Pi Zero using the official Raspberry Pi Imager, available here.
Install DeepPicar Repo
Clone the DeepPicar repository and install dependencies:
git clone --recurse-submodules --depth 1 https://github.com/CSL-KU/DeepPicar-v3 cd DeepPicar-v3 sudo apt update sudo apt install libatlas-base-dev sudo apt install libopenblas0 sudo apt-get install python3-opencv sudo pip3 install -r requirements.txt
Configure Drivers
Edit the
params.pyfile to select the correct camera and actuator drivers.
If you are using parts from the build list, you can skip this.camera = "camera-webcam" actuator = "actuator-drv8835"
Setup Driver for Pololu DRV8835
To install the Python driver for the Pololu DRV8835 motor controller:
cd drv8835-motor-driver-rpi sudo python3 setup.py install
Setup Gamepad Support (Logitech F710)
If you’d like to use a gamepad for data collection, set up the
inputsPython package:cd inputs sudo pip3 install .
IV. Test
Login to your Pi
SSH into your Pi over local WIFI
Before you start driving your car, make sure to enable legacy camera support.
$ sudo raspi-configNavigate to interface options, select legacy camera, and click on yes.
Start the control script
$ cd DeepPicar-v3 $ sudo nice --20 python3 deeppicar.py -n 4 -f 30Keyboard controls:
A: move forward
Z: move backward
S: stop
J: turn left
K: center
L: turn right
R: start/stop recording
D: turn on DNNUse the keys to manually control the car. Once you become confident in controlling the car, collect the data to be used for training the DNN model.
The data collection can be enabled and stopped by pressing
R. Once recording is enabled, the video feed and the corresponding control inputs are stored inout-video.aviandout-key.csvfiles, respectively. Later, we will use these files for training. It can be downloaded using scp commands.Each recording attempt will overwrite the previous.
Compress all the recorded files into a single zip file, say Dataset.zip for Colab.
$ zip Dataset.zip out-*Train the model
Open the colab notebook. Following the notebook, you will upload the dataset to the colab, train the model, and download the model back to your PC.
After you are done training, you need to copy the trained tflite model file (
large-200x66x3.tfliteby default) to the Pi using scp commands.Autonomous control
Copy the trained model to the DeepPicar.
$ cd DeepPicar-v3 $ sudo nice --20 python3 deeppicar.py -n 4 -f 30Enable autonomous driving by pressing A to go forward then D to start the DNN.