R2-D2 Line Follower

Project Duration: April 2019 - June 2019

Team: Joshua Cho

Acknowledgements: Nick Marchuk


Introduction

I built a line follower robot based on the Star Wars character R2-D2 as the final project for the course at Northwestern called ME433: Advanced Mechatronics. This robot was my entry for the Northwestern Tech Cup 2019, a competition to determine which robot that can follow the line around in a loop the quickest.


Design Overview

For this project I built a simple robot that can detect a black line on a white background using an external camera module. The microcontroller of choice was PIC32MX270F256D, the microcontroller I became familiar with over the course. The entire robot was powered by a 2S 500mAh LiPo battery. The motors used were standard 6V N20 DC motors from Pololu and were driven by the DRV8835 H-bridge. They were mounted on the "legs" of R2-D2 using M1.6 screws. Lastly, I added a small servo at the top to recreate R2-D2's turning head.

My robot was built with just 3D printed parts, and laser-cut pieces of 1/8" thick acrylic. Most acrylic pieces were joined together using 4-40 fasteners in t-slot joints.

I found this design very useful in creating a sturdy 3D structure out of thin acrylic sheets. The 3D-printed wheels were attached to the motor using propeller adapters normally used on quadropters.


Navigation

This robot navigates using an OV7670 camera module attached at the front bottom. The angle at which the camera is attached is adjustable, depending on how far ahead the camera needs to see for the robot to properly follow the line. The camera captures an image and it stores the brightness values of each pixel in a single row in the captured image. I then used a center of mass algorithm to track the location of the black line with respect straight-line path of the robot. Knowing where the black line is, I used PID control to turn the wheels so that the black line is maintained at the center of the camera frame.

Although this method worked, I was not able to get the robot to follow the line very fast. This was due to some design errors I made. First, the camera was way too close to the ground, so it can see only a couple inches ahead. Coupled with the slow update rate of the camera data, the robot could only move and turn so fast before losing track of where the line is. I also underestimated the weight of the acrylic head, which caused the robot to be very top-heavy and unstable (as can be seen in the video). Therefore, I had to wait for the robot to come to a complete stop before capturing the image to avoid noisy data.


Demo


Conclusion

This project was a lot of fun because I was able to get creative with the design of the robot. I enjoyed seeing my ideas come to reality and seeing one sheet of acrylic turn into a full robot. I also learned so much in terms of mechatronics, optimization, and control. I would love to make improvements to this robot and test it again in the future.