Urban DIY Robocar Build Notes

Intro

Here's my log of a build of a 1:28 scale self-driving RC car built to complete something akin to the DARPA Urban Challenge, in my living room.

This will be something like a DonkeyCar, but driving at much slower speeds through a cardboard urban environment. It should have figurine pedestrian/cyclist detection and traffic light handling, as well as localization, dealing with other vehicles, etc.

Parts

Initial build

Just enough to verify I can drive-by-wire at slow speeds.

PartPrice
WLToys K989$50
L298N motor driver H Bridge$7
Gear Motor with encoder 12v 977 RPM$16

I already have a 12V battery (which will replace the 7.4V that comes with the car) and RPi.

Build

Step 1: Drive-By-Wire

The WLToys K989 is a ready-to-run (RTR) car, so there's a lot of stuff it comes with that I don't want/need and must strip out: remote, transmitter hardware, integrated ESC.

Since I'm using a different motor, I plan to replace the battery with a 12V one and remove the old motor. The new motor will be driven by the H Bridge, connected to the 12V battery and controlled by PWM from the RPi. It's not immediately clear to me if the new motor will actually fit in the space available, so I'm crossing my fingers and hoping.

The steering servo will stay, but will be plugged directly in to the RPi. Hopefully the generated PWM signals from the RPi are good enough for these purposes. If not, I'll need a servo driver controller.

Picture of the K989's steering servo connector

The steering servo looks like a standard servo including the connector, so this should be easy.

10/1 Update

After playing with the received car, change of plans. The built-in brushed motor can actually move slow enough for my purposes, so I'll be leaving it in place (simplifies the build greatly) and instead building a drive-by-wire on top of the existing hardware. I tried to devise ways to control the existing ESC+receiver combo (it appears to have pinouts to reprogram it), but after an hour I gave up and ordered a standalone ESC and servo driver. This brings the build closer to the DonkeyCar setup, but it should remain fairly straightforward and reproducable with simple instructions. I'll find some other project to use the L298N and gear motor in.

10/6 Update

Drive-By-Wire success! By using the standalone ESC and servo driver, I was able to control traction and steering out of the box with DonkeyCar code. The only minor hiccup was that the servo motor actually needs another V+ pin connected on the PCA9685 in addition to the VCC, which is intuitive if it's not 12:30am. Here's the traction motor working -- I'm using my Exceed DonkeyCar as a primary because I don't have scaffolding printed yet for the WLToys, nor do I have another Pi ready to go.

I'm in desperate need of a workbench, too. But the good news is that it looks like getting a WLToys car hooked up with DonkeyCar requires just an ESC, and otherwise will cost notably less than a magnet car setup.