A school project at Howest (Smart Tech & AI Creator) asked for a research question, answered by building something. So I needed a question that a prototype could prove or break.
My question:
Can a neural network run on a Raspberry Pi and steer a radio-controlled car around a track?
Self-driving companies stack huge networks and sensors on top of each other. I wanted the opposite: one camera, one small network and one cheap computer, and a car that shows where the limit sits.
The demo
The car on its test track, driving itself.
Under the shell
An RC car with its original electronics swapped out. A Raspberry Pi 3 does the thinking, a Pi Camera V2 does the seeing, and a motor driver and servo turn the wheels. The Pi runs on a power bank, the motor on its own battery. The test track is blue tape on a wooden floor.
Learning by imitation
The car learns what a road is from examples. Every camera frame is stored with the steering angle at that moment, recorded while the car is driven by hand with a potentiometer on top as a steering wheel.
The first recordings are mostly straight lines. A network trained on that bets on "straight ahead" every time, so the dataset gets rebalanced to give corners more weight. The balance improves visibly. It stays a little lopsided.
Every frame is then simplified before the network sees it, so it learns the shape of the track and ignores the room around it.
- Raw frame: straight from the camera.
- Brightness: RGB converts to YUV, which separates brightness from colour and makes the tape stand out.
- Road mask: everything outside the area where the road appears turns black.
- Edges: a Gaussian blur removes noise, then Canny edge detection keeps the outlines of the lines.
- Network input: a tiny image, which holds all the detail the network needs and keeps it fast on the Pi.
More road than there was
One afternoon of driving captures a narrow slice of the world. Flips, darker frames, random shadows, rotations and shifts stretch the training set, so the network meets lighting and positions that never appeared on the floor.
The network
A convolutional neural network with nine layers. The first normalises the image, five convolutional layers pick out features, and three fully connected layers merge them into a single number, the steering angle. TensorFlow and Keras train it on a PC, because the Pi is too slow for training. TensorFlow Lite then shrinks it for the car.
On the road, a Python script on the Pi grabs a frame, runs it through the model and sends the angle to the servo, about ten times per second.
The result
On an unseen track, the car completes the course flawlessly. The steering angle lands within 10° of the target on a 180° range.
The Raspberry Pi has exactly enough power for the job. Data quality decides how well the car drives.
