As explained in my last post some time ago, I recently gained interest in the area of autonomous cars, so I decided to write a series of posts on building a small autonomous car using an RC car chassis, in the hope that they may be helpful for anyone going down this path. This post is the first of the series.
Disclaimer: Some of the links that follow are all affiliate links to products on eBay or Amazon. Please read our Affiliate Link Policy for more information.
While the term “autonomous” may bring to mind images of vehicles rigged up with dozens of sensors, rangefinders, complicated control loops and telemetry systems, the premise in the case of this project actually much simpler than that. The goal is to build an autonomous car that can drive around a marked track1 using monocular vision, i.e. a stream of images from a single camera. This definition sets lower expectations than full autonomy2. It is still very exciting and rewarding though once you see the little cars moving about by themselves. Vision-based approaches are naturally software intensive. On the hardware side just a plain camera is usually enough, while at the software side complex algorithms are used to process the image and make driving decisions.
Nevertheless, a good hardware foundation is in order, so this first post will be about hardware, not software. I will share my experience in building a simple, compact autonomous car that is suitable as a research platform in autonomous driving. For my build I’ve used mostly off the shelf parts, and where custom parts were required, I tried to keep processing to the bare essentials. I’ve also placed a list of parts I bought at the end of the post, so for those of you that can’t wait:
The rest, follow along!
The autonomous car chassis
Let me put it simple: Anything that has three or more wheels, and can move fore, back and steer. You can get a $10 robot chassis, or a $500 RC car, and, at this point in time there will be little difference. This is because as of the time of writing the state of the art in DIY autopilots runs at speeds of approximately a few meters/sec. IF however you’d like to invest in the future where hopefully those speeds will increase, you could get a good quality RC car to handle those corners and bumps.
The mini trooper is a nice little chassis that has four-wheel drive and independent suspensions with oil-filled shocks. The latter is important if you plan on encountering rough terrain, and overall will help in keeping the camera picture free of vibrations as well4. The suspensions are adjustable, which will come in handy in adjusting your ride height after you’ve added the RPi and other equipment.
I went ahead and replaced the stock brushless ESC with a Hobbyking 30A car ESC, because I’ve read that the stock ESC is crap, and can only drive the brushless motor at high speeds and in discrete speed steps. This might be ok for folks bashing the **** out of their cars, but for autonomy it is unacceptable. The new ESC has the added benefit that it includes a 2A max linear BEC. While this is barely enough to run the whole bunch of RPi+NAVIO2+Wifi+Servo (which I’m currently doing), it may help as a power source for the steering servo.
The Upper Deck
I’ve installed a wooden upper deck to house various electronics. This seems to be a common solution among RC autonomous car folks. The main aim of the upper deck is to provide a secure attachment for most electronics, namely the RPi+NAVIO2, TL-WN722N Wifi adapter, and the camera together with the camera “rig”, which is just a fancy name for a raised vertical plate i glued together to fix the camera onto.
I bought some chipboard of around 3mm (anything would be ok really) and cut out a couple rectangular pieces. The biggest one I measured to be a bit longer than the distance between the RC car body posts (holding the original plastic body), and around 10cm wide. I cut the rest to a bit arbitrary dimensions and glued them together with white wood glue for a clean, strong bond. Turned out quite stiff indeed.
To mark the spots for drilling the plate post holes I just spread two dabs of regular board marker on the tip of the posts, and pressed the plate on top of them, being careful to hold it parallel to the car. This left four spots on the plate, which I then easily drilled out. The plate was a good fit on the first try. I secured the plate with the included pins5. I did the same trick adding some paint on the screws under the RPi board, to get the positions needed to screw the RPi board on the wooden plate. Later on I drilled a bunch other holes for cable pass-throughs and cable ties.
The battery is connected straight to the ESC using an XT60 connector, which I soldered to the ESC cables6. One thing that I enjoyed a lot as a RC car first timer is the presence of a physical switch on the ESC. The switch allows to turn on and off the whole system with a single flick. No such thing on a multi-rotor for sure, as it would be just extra weight. The NAVIO2 board (and Raspberry) is powered by the ESC BEC through connection to the servo rail. The steering servo of the vehicle is powered and gets its signal from the servo rail too. Finally, the RC receiver gets it’s power, as well as the Sbus communication, through the receiver pinout on the NAVIO2.
The Donkey team have been running autonomous cars where the camera is mounted above the electronics platform at an angle. This makes sense as in this way the relatively narrow angle of the RPi camera can capture more of the road ahead. I followed the instructions and mounted the camera facing approximately 15 degrees downwards. I mounted the camera at a total height of around 20 cm (7.87 inches). That’s still a bit lower than the 1/10 vehicles, but I didn’t want to build the camera rig taller. In addition, I’m using a camera lens that increases the viewing angle of the camera. That way I can capture features nearer to the car. The view form the camera looks like below:
However, if I was to buy a Raspberry camera module now, I’d got for the fish-eye module (Here’s a listing on ebay), and this is what I list below as well.
Autonomous car parts list
This list has been revised as of Feb. 15 2018.
I’m also listing here an RC Transmitter and Receiver to interface with NAVIO2 and control the autonomous car. This is optional and the car may also be controlled via WiFi:
This post outlined the build process of an autonomous car, focusing on the hardware. In Part II of this post series we will dive into setting up the autopilot software for our car.
What’s your experience with autonomous driving? Share in the comments below!
- Here we refer to a plainly marked track, i.e. using tape, spraypaint or another visually distinctive means.
- also known as L5 autonomy; for a good explanation of levels of autonomy see this article
- The car comes with a cover as well, but I really hate those car-looking covers, so I just left it in the box the car came in, and never really plan on using it. If I’ll ever add a cover, for sure it won’t be an immitation of a full scale car with a passenger cabin!
- Although it does mean that the car will roll more heavily in tight turns.
- Ideally you could add a bit of foam either side of the plate where the posts pass through. This should make the connection more rigid, and help absorb any rough vibrationscoming from the car chassis
- This particular ESC comes with bare pre-tinned leads