As explained in my last post some time ago, I’ve recently gained interest in the area of autonomous driving, and in particular autonomous RC cars. Thus I’ve decided to write a series of posts on the topic, in the hope that they may be helpful for anyone going down this path. This post is the first of the series.
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 RC car that can drive around a marked track1 using monocular vision, that is, the stream of images from a single camera. This definition sets lower expectations than full autonomy2, but as a premise is still very exciting, challenging and rewarding once you see the little cars moving about by themselves. Vision-based approaches are naturally software intensive, i.e. on the hardware side just a plain camera is usually enough, while at the software side complex algorithms are those that actually process the image and make decisions regarding car driving.
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 car that is suitable as a research platform in autonomous driving. For my build, I have 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 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 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. In my case, I went somewhere in between and bought a 1/16 RC car from Hobbyking, the Turnigy Mini Trooper. You may see the finalized chassis, after modifications, below3.
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.
2. The ESC
I went on 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 self driving purposes 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 good servo power source.
3. The Upper Deck
I’ve installed a wooden upper deck to house various electronics. This seems to be a common solution among autonomous vehicle folks using RC cars as a platform. The main aim of the upper deck is to provide a secure attachment for most electronics, namely the RPi+NAVIO2, Wifi card, 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. The rest were cut to a bit arbitrary dimensions, meaning that they could be almost anything really. I 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, that allows one to switch off the whole thing 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 also from the servo rail. 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 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, at a total height of around 20cm. 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 in front of the Pi Camera that increases the viewing angle of the camera, so as to 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, and this is what I list below as well.
I’m also listing here an RC Transmitter and Receiver to interface with NAVIO2 and control the car, although this is optional and the car may as well be controlled via WiFi:
This post outlined the build process of an autonomous car, focusing on the hardware. Stay tuned for Part II of this post series, where we will dive into setting up the autopilot software for our car.
- 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
- You’ll also need an XT60 connector, three 3.5mm banana plugs, and soldering equipment for thi ESC, as it comes with bare wires