Building an AI Community with DIY Robotics: Part 1 — The Donkey Car

Dan McCreary
5 min readDec 29, 2018
Using DIY Robotics to Build an AI Community

This is the first in a 3-part series on the Donkey Car. Here are links to part 2 and part 3.

I have been building robots for teaching kids computer science through the CoderDojo program for almost four years. This has been a rewarding experience and I have learned a great deal about building Arduino kits and simple robots. I have been creating “learning ladders” for kids 8–18 and my robots are used by kids as young as 5 years old at The Works Museum. Building a STEM curriculum around DIY projects is fun and a great way to find a community. You can see some of my work at the Moving Rainbow and CoderDojo Robots sites.

With the new year, I have decided to extend my comfort zone to include more complex robots based on the Raspberry Pi, Python and machine learning. My friend, Arun Batchu, has also been encouraging this with his purchase of a very cool NVIDIA Jetson Xavier developer kit. Unfortunately my little robots are not powerful enough to run this 9-billion transistor System on a Chip. I thought this would be a good way for me to brush up on both the latest in image recognition and the hot topic of edge computing. Building a local DIY robotics group also be a way to build a stronger AI community in the Minneapolis area.

For those not familiar with the Donkey Car project, it is an Open Source DIY project to get people to learn the basics of real-time image recognition and a bit of AI. The parts for the car run about $250. This is 10x more expensive than my Arduino robot but it is also a lot more powerful. In the Bay Area there are over 2,500 people on the DIY Robocars meetup and there are almost as many on the Donkey Car Slack workspace with thousands of posts on cars, tracks, algorithms, machine learning models and related topics. We don’t yet have a community like this in Minnesota, but I hope to change this!

The following is a journal of the work I did to get started building a Donkey Car. So as they say…we are off to the races!

I was “gifted” a Raspberry Pi 3 B+ Kit at the last MinneAnalytics conference by the great guys at Swarm64, including Paul McCullugh and Thomas Richter. Swarm64 makes great accelerators for RDBMS systems using FPGAs. If you need a faster relational database give them a call!

The Raspberry Pi Kit included a 32GB micro SD card with the PI OS on it, a power brick, a GPIO breakout and a case as well as some other parts. I added a $27 SainSmart Wide Angle Fish-Eye Camera and a PCA9685 16 Channel 12-Bit PWM Servo Motor Driver along with a new $90 RC car (which I have not tested yet). I tested the Pi by using the GPIO to blink LEDs using the Thonny Python IDE and found a DMA library for controlling LED strips. I also picked up two extra 32GB SD cards at Microcenter in St. Louis Park for $4.99 each. This is a LOT less then I could find on Amazon. Microcenter really rocks! I would suggest getting several micro SD cards so you can make backups.

After many years of doing work in “C/C++” on the Arduino I was a bit surprised at how hard it was to get started on the Pi. There are many libraries that need to get installed in the right order and many versions of Python that need to be considered. The Thonney Python IDE was nice, but it lacked most of the libraries we need to do serious work with TensorFlow. The good news is that once the libraries are setup coding goes pretty fast. If you are doing hardware programming with physical devices there is no “lag” when you make a change to your code and have to upload it to the Arduino. The programs run instantly! I think this could speed up development, especially when you have large programs.

Now onto the Donkey Car… The Donkey Car web site is pretty well done, but it assumes a very strong background with both UNIX and the Pi. When they gave instructions it was not clear I should be running things on my new Pi or from a remote computer. I spent about two days trying to get various Python and TensorFlow libraries to work natively on the Pi. Although I learned a lot in the progress, it turned out to be a dead end. The Pi, with just 2GB or RAM, is just too small to compile the massive TensorFlow-Keras system without heroic effort. Even on a Mac with 16GB of memory I ran into bugs with the TensorFlow compile system based on Bazel. The Bazel build framework itself is incredibly complex, and you need Bazel to compile the TensorFlow monster. Make just didn’t cut it. I was about to give up. If a person like me with 25 years of experience with UNIX could not install this thing how could I hope to train my 14 year old students?

Then I started to realize that everything that is done on the Donkey car makes an assumption of a headless Pi (no monitor, just a SSH access) and uses their disk image that has been carefully crafted over three years by Linux and Pi experts. You need to boot on their Pi image and everything else works! You just can’t use the Pi as a development system. The TensorFlow documentation does say this but I didn’t RTFM.

I struggled a bit to understand how to build a boot image for the Pi based on the Donkey image (a zip file that contains a disk image). After trying the NOOBS system I realized that the balenaEtcher application is exactly what I needed. The application is very simple to use on a Windows or Mac. You just download the image zip file from the Donkey Car site, put a new SD card in and run the belenaEtcher application. It prompts you for the image file (no need to uncompress the zip file), it found the SD drive automatically and then I just clicked “Flash”. Poof! In just a few minutes I had a verified disk image.

After rebooted on the new SD into my Pi I could login and changed the wifi settings. One more reboot and I was ready to ssh into my new Donkey Car. I also setup a static IP address so it would reconnect to the same IP address each time. A file count under the “/home/pi/env” directory revealed almost 13,000 files. If you want all the gory details I put them in a comment-enabled Google Docs file here. Feel free to add comments to that file.

I will be posting updates as I make additional progress and after other parts arrive. I will need them to do the calibration step.

--

--

Dan McCreary

Distinguished Engineer that loves knowledge graphs, AI, and Systems Thinking. Fan of STEM, microcontrollers, robotics, PKGs, and the AI Racing League.