Donkey Car Part 3: Yes, you can learn autonomous driving for under $250

Image for post
Image for post
Concept Map for learning to drive the Donkey Car. Green are starting concepts, blue for intermediate and black are advanced “finishing” concepts.

This is part 3 of a series. Here are links to part 1 and 2. After several long days of struggling I finally got my Donkey Car to drive autonomously around the track in my basement! There is a short video here: https://www.youtube.com/watch?v=Bpt8NZdQLrU

So here is what tripped me up. When I uploaded my model from my Mac to the Pi and ran the “Drive” command I was getting errors loading the model. I kept rerunning the steps and got the same errors. It took me a few days to realized that I was running an old version of TensorFlow (1.8) on the Donkey Car and a newer version of TensorFlow 1.12 on my MacBook Pro. I also posted a question on the Donkey Car help Slack channel and they confirmed at the models built with newer TensorFlow version 1.12 would not run on older versions of TensorFlow. Once I figured out how to downgrade the TensorFlow on my Mac (a one line pip shell command) I reran the training, transferred my new model to the Pi using SCP and my car was off and running….that is after I realized that I had left the camera lens cap on…

I started with a relatively small training set of around 16K images. The training took 55 minutes on TensorFlow 1.12 but 75 minutes on TensorFlow 1.8. 1.8 came out in April of 2018. Lets hope the DonkeyCar image gets upgraded soon so we can all take advantage of these performance improvements! I also just was using a test set of driving counterclockwise around the track. In a real race I would train the car with both clockwise and counterclockwise runs. But that would also add to the time to build the models.

Although the car can get around the track, it is easily fooled by the reflections of lights on the floor and other white objects on the side. This is because I am using just a single white line of tape on my floor. That is not quite enough signal for the vision system to use. However, I don’t think my wife really wanted me to paint a wide black “road” with yellow stripes down the middle like the official Donkey Car track uses.

When I finally got the car to work in autonomous mode it was quite gratifying. But is was also a bit “spooky”. I actually “taught” a little brain to follow the line on the floor. It almost seemed to mimic my poor driving. It even learned how to speed up on the straightaways and it slowed down on the tight curves. That was really cool!

Although I have been doing some work with TensorFlow and Keras at work, many of the steps were a bit abstract. Once I started to play with the Donkey Car things were more understandable. Both the strengths of the system and its weaknesses became clear. I also realized that getting the Python and TensorFlow library versions synced between both the training system (my MacBook) and the inference system (the Pi) was a critical step.

After going through all the steps once I now understand most of the components and I am building a “concept map” that can be used by others to help understand what concepts they need to know to get their Donkey Car running.

I am now retracing all the steps I have learned and integrating the steps with the prior work I have done building concept cards for our local CoderDojo club. This is the figure at the top of the blog post. Each of the boxes in the concept map will eventually become a 1/2 sheet of laminated paper with activities and questions on the front and answers on the back. These are called “Sushi Cards” in CoderDojo since they are bit-sized bits of learning. Here is a sample image of the “Electric Motors” concept card:

Image for post
Image for post
Electric Motors Concept Cards for AI Racing League.

My friend Jon Herke is also interested in using the Donkey Cars to build an “AI Racing League” that would target teaching kids about AI and robotics. Stay tuned to see if we can build a foundation for hackdays and a 10-week, 4-hours/week summer camp type program. We hope to get girls and disadvantaged youth involved in these programs. Let us know if you are interested in helping us get started.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store