Building a Raspberry PI remote controlled car with my 13-year-old

TLDR: Instructions on how to assemble and use the car: https://github.com/vcollak/AutoBot

About a year ago I brought a Tamiya remote controlled bulldozer back from a trip to Japan. It looked like a very simple kit to assemble, and I figured that my 13-year-old son and I could work on that together. What I liked about it most is that it required a gearbox assembly. I thought it could be very interesting for both of us to learn how gearboxes actually work. Sure enough, my son and I had a ton of fun assembling the vehicle. At the end of the “project” we had a car, but unlike most remote controlled vehicles, this one was NOT wireless. It literally had wires that lead to a simple plastic remote controller. We thought that was a bit too old school and imagined how cool would it be to control the vehicle straight from an iPhone. All we need is a Raspberry PI and maybe some simple software and we’re up and running, right?

So, we bought the PI and put Linux on it. Next, we researched how to drive the motors using the PI. As it turns out, a good way to do this is to use a motor driver so we bought one from Pololu. As an added benefit, a voltage regulator can be used with the driver to power the vehicle via an external battery (as opposed to doing that via the standard USB port). One caveat is that these components required us to solder things together. We also needed to figure out how to place the PI on the car kit, so we designed and created a simple wooden plank that would fit on top of the kit. From a learning experience, I think having to solder was very good. I’m sure it’s not something kids commonly do, so I was glad that my boy was able to experience it. It was also very good to collaborate on a design of our plank. We discussed all kinds of ways we could mount the PI and the battery, and ended-up with something that worked very well. It allowed us to think creatively as opposed to just following the instructions.

Once the hardware was complete, it was time to turn to software. We decided to use Python since the Pololu motor driver already had a low-level software driver and a test utility to run the motors. From a design perspective we wanted the remote controller to be:

  • web based
  • mobile friendly
  • communicate in real-time
  • have no need to connect to the car directly

That design decision was mainly so we could eventually control the vehicle over the Internet without the need to know the car’s IP address and punch holes through firewalls. Imagine a car in one place and a driver in another — that was the idea. Needless to say, that design complicated quite a bit. We had to write a communications server that would sit in the cloud somewhere. This server would receive messages from the remote controller and in real-time pass them to the car. We spent a good amount of time researching the best way to get this done. We tried various libraries and approaches such as AutoBahn, SocketIO, and WebSockets. Our overall strategy was to prototype simple communication between the two applications (controller and car), and then once we figured out the basic framework, make it more robust. In the end, we decided to write a multi-threaded server that listens to connections and uses a common queue to pass messages between threads. Lessons learned from this part of the project were that we ended-up writing way more code and much more complex code than we expected. Also, not surprisingly Python was a lot of fun, but there is so much more depth and complexity to it than originally anticipated.

Overall, we’re pretty excited to complete the project. We both learned a lot and had fun. Check out the video of the final product:

If you want to check out how we built the hardware and what we ended-up creating in terms of software, take a look at this GitHub repository: https://github.com/vcollak/AutoBot

Like what you read? Give Vladimir Collak a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.