Building and Running a DonkeyCar in Bangalore — my journey so far — Part 1

TLDR:
- Build a Donkey RC car using off the shelf components, procuring some of them is tough from Bangalore, but can be done ;-)
- Train the model using Amazon SageMaker on a test track
- Run the car with the trained model
Rinse and repeat …
I owe a lot to my young colleagues Rahul Kulkarni (and Akash Jain) who woke me from my slumber and got me restarted on my stalled project !!
Donkey is a high level self driving library written in Python, conceptualised by Adam Conway and William Roscoe. It enables any hobbyist to build a self driving platform for small scale cars using a Radio Controlled (RC) Car with Raspberry Pi + some more hardware components, collect samples, train the model using Keras (and other ML algorithms) and run the car using the trained model. I wanted to share my experiences of building this car in Bangalore, and this hopefully should help other enthusiasts to get started quickly.
Please note that the documentation at https://docs.donkeycar.com/(please see the Resources section below) is very exhaustive, and I will not go over the steps again ..
I started hearing about Donkey Car almost a year back on the internet, primarily on twitter. There has been a lot of buzz around this concept since last year …

At reInvent 2017 last year, there was a RoboCar Rally which centred around using deep learning and the open source Donkey Car platform with AWS machine learning services and AWS IoT — https://aws.amazon.com/blogs/machine-learning/congratulations-to-the-winners-of-the-reinvent-robocar-rally-2017/
Building the car:
The toughest part for someone sitting in Bangalore, India is procuring some of the hardware parts. The toughest parts to get was the R/C car — importing it into India and paying customs duty was the toughest part. The Raspberry PI, the Donkey Car plastic frame, other components like Raspberry Pi camera was relatively easy. I would suggest buying the car and the parts abroad, if you travel frequently or order them via amazon.in or ebay.in. In fact, even the small screws needed to screw the board to the frame was also next to impossible to find in Bangalore. I started collecting the parts one by one last year, and very soon lost interest, as it is a difficult and laborious process to acquire, build them. Its a test of faith and patience !! Thanks to my colleagues, Rahul and Akash, who built and demo’ed them a few months back, which gave me the confidence to try the process again.
Anyway, my final car looks like this ..


Building the test track
This is still a work in progress. This requires dedication and lots of space. In my first attempt, which I am not yet happy, I used my terrace with the test track using ribbons. The wind, rain and the variable sunlight has not produced good results, I am planning to create an indoor track with a painted and simple circular track.
Installing the software
We have a choice of software platforms to train the models, from Windows to Linux PCs to Amazon SageMaker. I used Amazon SageMaker — AWS’s fully-managed platform that enables developers and data scientists to quickly and easily build, train, and deploy machine learning models — https://aws.amazon.com/sagemaker/ . Please make sure you use a p series instance type for training the model, I used a ml.p2.xlarge and use the documentation at https://docs.donkeycar.com/guide/install_software/#install-donkeycar-on-aws-sagemaker
Driving the car
Driving the car using the browser is extremely tricky and needs patience and slick hands. Using the Joystick mode and the touch pad on a mobile browser seems to work — https://docs.donkeycar.com/guide/get_driving/

During the test runs with the car, the data is collected and stored as hundreds of small jpeg images and JSON files.

{“user/mode”: “user”, “user/angle”: 1, “cam/image_array”: “2638_cam-image_array_.jpg”, “timestamp”: null, “user/throttle”: 0.19752573191495948}
This needs to be transferred to the server to train the model using Amazon SageMaker. Data transfer between Raspberry Pi and Amazon SageMaker can be done using Amazon S3 as an intermediary. We can install S3 client on Raspberry PI.

So, finally after all this, we transfer the trained model from Amazon SageMaker to the Raspberry PI onboard the Donkey Car. Running the car using a pretrained model, and this is what happens !!
So, obviously it needs to perform better with better training and a better track ..
Whats next ?
Need to do the following:
- What the heck happened ;-) Need to look closer at the code and understand the ML side of things ..
- Create a better track, run the Car and train the model ..
- Implement some of the add-ons done by the AWS team — Sunil Mallya and Justin at https://aws.amazon.com/blogs/machine-learning/build-an-autonomous-vehicle-on-aws-and-race-it-at-the-reinvent-robocar-rally/
I will post a Part 2 soon, sharing more experiences ..
Resources:
- The Donkey car home page — http://www.donkeycar.com/ and https://docs.donkeycar.com/
- The Make magazine article — Build an Autonomous R/C Car with Raspberry PI — https://makezine.com/projects/build-autonomous-rc-car-raspberry-pi/
- AWS Blog — Build an Autonomous Vehicle on AWS and Race It at the re:Invent Robocar Rally — https://aws.amazon.com/blogs/machine-learning/build-an-autonomous-vehicle-on-aws-and-race-it-at-the-reinvent-robocar-rally/
