June 30 2019, Sunday

Adventures building a Self Driving RC Car

Having read some amazing books on Machine Learning, I had been looking for opportunities to apply ML from first principles in the real world. That was what got me curious about the wonderful Donkey Car project. The project is essentially a how-to guide to building your own RC car which can drive itself around a track using classicial control theory, computer vision or in my case Machine Learning. After attending a DIYRobocars meetup, I could not wait to build my own car.

I knew I wanted to do something different with my donkey car. So for my first build I chose an Asus Tinkerboard S, a JeVois camera and other standard bill of materials.

I went with a Asus Tinkerboard S despite knowing that most members of the Donkey community were using a Rasbperri Pi 3B+. My main motivations were:

I chose the JeVois camera because I liked having the freedom of doing some computer vision as well. The JeVois is a full-fledged Linux computer which has an on-board GPU as well. I ended up taking advantage of the camera by implementing a fast contrast stretching algorithm to normalize for lighting conditions as a preprocessing step for the ML model.

Learnings

Choosing the Asus Tinkerboard S required me to understand a lot about the donkeycar framework. This was because everything in the documentation assumed that you were using a Raspberry Pi and in my case I was not. To make matters more difficult I had also chosen a different camera so I to write my own module to make things work.

I also realized that, while the Asus Tinkerboard S had advantages over the Raspberry Pi 3B+, I had just enough headroom to run the stock Nvidia End to End Self Driving model at a resolution of 160 x 128 px.

Hello, Jetson Nano

I wanted to experiment with more sophisticated models. As i was constrained by the CPU on the Asus Tinkerboard S, I decided to level-up using the Nvidia Jetson Nano.

The Nvidia Jetson Nano is an amazing single board computer which has a real GPU with 128 CUDA cores. Nvidia also has great software support including their Jetpack SDK, and they ship a customized version of Tensorflow 1.13.1 for the Nano.

For the last couple of weeks, I was busy building a new car with the Jetson Nano.

Top View

Side View

The Jetson Nano has been an absolute joy to use. I am running both the fast contrast stretching algorithms, as well as the ML model on the GPU. I compiled Open CV 4.1 for the Jetson Nano and contributed a how-to guide on doing that.

A few more tweaks after, and I had Donkey 3.0.2 running really well on a Jetson Nano. I also added some more components to the bill of materials including a PiOLED Display which I added to the car to display some stats. The source code for this additional module is here.

The Race

The race was a lot of run, and I managed to do my personal best which was a lap-time of 13.1s around the track. My 3-lap timing was 37s. My previous finish was 27s for 1 lap. (I have come a long way).

Here is a video of the race. The first one was my best, and in the second video I tried to make it go faster.


Epilogue

If you are wondering why the car looks familiar, @NvidiaEmbedded recently tweeted a picture of my car. Thank you for the shout-out @NvidiaEmbedded.