Work

Self Driving Car Project

I improved the self-driving car project for UBCO's Applications of Engineering Design course.

A small car with a raspberry pi and camera attached to it.

One course I took at UBCO was Applications of Engineering Design. This course was a great experience as it was a project-based course where we were given a project to make a self-driving car using machine learning. During the course I saw a big opportunity to improve the underlying code and make the car more reliable. I was able to improve the car’s performance by offloading the machine learning to a laptop which was way faster than the Raspberry Pi and then streaming the results back to the car over a socket connection. This was a great learning experience for me as I was able to learn a lot about how to use sockets to build real-time applications.

What steps did I take to improve the car?

The first thing I did was to have a look at the existing code and see how I could improve it. Unfortunately the existing code was almost completely illegible and had no comments. There was about a dozen different files with no clear structure and each had over 1000 lines of code. I decided to start from scratch and build a new codebase from the ground up. The first thing I did was try to control the motors of the car, to do this I wrote a small python script that let me turn the motors on and off. Now to get the car to accept commands from the laptop I wrote a node.js server that would accept commands and forward them to the python script.Once this was done I was able to control the car from the laptop by simply importing socket.io and sending commands to the server.

Next I wanted to get the car to stream video to the laptop. I was able to do this by using mjpg-streamer which is a great tool for streaming video from a raspberry pi I actually used it before on my 3D printer to get a live stream.

Finally to record the training data for the car I wrote a desktop application using electron that would record the video and the commands sent to the car. This was a great learning experience for me as I was able to learn a lot about how to build desktop applications using electron.

Improving further

My professor was so impressed with the improvements I made to the car that he asked me to continue working on it for a Co-Op work term. I was super excited as I had already learned a lot about the car and was eager to continue working on it so I jumped at the opportunity. I was responsible for writing lab manuals for the car and also providing guides for how to build machine learning models for the car. I also collected training data for the car and built a desktop application to record the data and control the car.

Software Utilized

Python TensorFlow Raspberry Pi Socket.io NodeJS TypeScript React Yarn OpenCV Electron Mjpg-Streamer LaTeX