In May of 2016, the Self Racing Cars group held their inaugural autonomous track day for full-size cars at Thunderhill Raceway Park in Northern California. Will and I both attended, but wouldn’t actually meet until a few months later. We were intrigued by the event, but we knew that full-sized autonomous racing cars were not for hobbyists like ourselves.
Then in November, Chris Anderson announced a hackathon for scaled-down cars (later named DIYRobocars), and we both showed up excitedly. The new mini series included a league for 1/10th scale R/C cars, which is a perfect scale for a low-cost car. I brought an R/C car, a Raspberry Pi, and some hastily 3D-printed and laser-cut parts. While I was assembling my vehicle, Will introduced himself to me and asked if he could help — thus beginning the partnership that has led to the creation of the Donkey Self Racing Car.
» Donkeys are one of the earliest domesticated pack animals.
» They’re safe for kids.
» They occasionally don’t follow their master’s commands.
» The word donkey has a negative or ugly connotation, so expectations are super low!
Initially I had modest goals of using computer vision line-following techniques with OpenCV, but Will was more ambitious. He wanted to leverage machine-learning techniques used in self-driving cars like those made by Google and Tesla, but the challenge was where to start.
The event ended with a race featuring all running cars. There were about six cars being hacked on through the day, but only three were up and moving by the time the race began. One of those was the one Will and I worked on, and although it required manual control via a terminal connection, it demonstrated motion and control with our basic hardware setup. One of the other cars, built by Otavio Good and Matt Ball, wowed the crowd with its high speed and ability to learn and autonomously emulate Otavio’s remote control driving. The open source code for their car, dubbed the “Carputer,” gave Will the machine-learning starting point he needed as we moved forward with the project after the event. I helped refine the hardware and “Team Donkey” is now competing and finishing races in the DIYRobocars monthly events. Even better, there are now about 10 Donkey vehicles up and running in the world — maybe after this article there will be more!
Donkey Car Overview
The Donkey autonomous car is a very simple car. It’s based on a Raspberry Pi computer, a camera, and a servo shield (or “hat”) board to interface with the R/C car. You drive the vehicle around a lined track to capture images and steering angles, which trains a neural-network autopilot to drive itself around the track. Top speeds around corners are about 4–6mph.
While collecting training data, the car itself doesn’t do all that much. It basically takes pictures and sends them to an Amazon server and gets servo commands in return. The server is where the magic happens. First it collects the images and driving information from the user manually driving the car around the track. The default way to do this on the Donkey is via the mobile-friendly web page delivered by the server.
The mobile web page even has a live video view of what the car sees and a virtual joystick. The server records data from a person driving the car, then uses those images and joystick positions to train a Keras/TensorFlow neural network model in software. This happens quickly — full trip latency (car > server > car) takes about 1/10 second.
Once trained, the model can be loaded on the car and the car should be able to drive like you. This how-to will teach you to get a car up and going.
How to Build a Donkey V2
While you can use these instructions to modify most hobby-grade R/C cars, these directions focus on modifying the Exceed Magnet 1/16th scale truck. Get an invite to our Slack channel to ask questions and post pictures.