This project contains the code to control an RC car with a Raspberry Pi, and navigate a paper track autonomously.
- Raspberry Pi (Wi-Fi capable, such as RPi 3 Model B)
- Pi Camera
- RC car that runs on 27 or 49 MHz band (this car worked well; found for $5 at a dollar store.)
In order to control the RC, the pi-rc library was used to turn the Raspberry Pi into a radio-frequency transmitter. Python functions for basic directional control are contained in rccontrol.py. To set up RC control, do the following from the command line on your Raspberry Pi:
git clone https://github.com/bskari/pi-rc
cd pi-rc
make
sudo ./pi_pcm -v
python3 host_files.py
See https://github.com/bskari/pi-rc for more information on how the RC commands are formatted, and troubleshooting.
In order to train the neural network, you must run collectData() in rctrain.py, which allows you to incrementally move the car through a paper track, recording a picture and the direction traveled at each timestep.
Before being input to the neural network, the images are grayscaled, cut in half (only the bottom half really contains useful info,) reduced to 288 x 96 px resolution, and flattened into a one-dimensional array.
In order to run the car in test mode, run rctest.py. In test mode, the program continually takes a picture and passes it through the trained neural network to choose the most probable direction to go: either forward, left, right, or reverse.
Libraries used:
https://github.com/bskari/pi-rc
Inspiration for the neural net architecture: http://blog.davidsingleton.org/nnrccar/
