This project integrated sensing and control with a two-wheeled robotic platform to autonomously follow a taped track on the floor. The system uses a closed-loop PD controller on an Arduino that can navigate a non-circular loop course. A key requirement was the ability to tune the controller and adjust robot performance in real-time via serial communication, without recompiling code, to achieve the fastest possible run times.
We designed a custom chassis to precisely control wheel-to-wheel distances, sensor placements and heights, and other design elements that would optimize our code's performance. We implemented a proportional-derivative (PD) control scheme using five infrared sensors:
The control algorithm stays centered on the line using the main sensors, only using the far sensors when the main sensors lose sight of the line. This approach enabled fast line following with consistent sharp corner navigation.
Our mechanical design focused on creating a stable, balanced platform. We positioned the motors and wheels in the back to maximize sensor turning radius and concentrate weight over the drive wheels for better traction. The chassis measures 5 inches wide by 6.5 inches long and uses a three-point contact system:
All design choices were based on precise measurements of physical components using a caliper, with appropriate tolerances for assembly.
Initially, we used three sensors positioned close together in the center. However, this design failed at sharp turns greater than 90 degrees because the sensors couldn't see the line during tight corners. To solve this, we added one sensor on each side, positioned slightly further back, to detect the line when the center sensors lost contact.
The sensors were positioned with 8mm spacing between the three center sensors - slightly wider than the tape. This made programming easier: when perfectly following the line, the middle sensor sees full tape color while the side sensors only partially see the line.
Each IR reflectance sensor includes:
We implemented a Finite State Machine (FSM) with two primary states:
The PD controller calculates an error signal and applies proportional and derivative corrections:
ERROR = (LEFT_READING - RIGHT_READING) CORRECTION = Kp * ERROR + Kd * (ERROR - LAST_ERROR) LEFT_SPEED = BASE_SPEED + CORRECTION RIGHT_SPEED = BASE_SPEED - CORRECTION
We created a Python GUI with serial communication that enabled runtime parameter adjustment without code recompilation. The interface features:
This dramatically accelerated the tuning process, allowing us to optimize performance through rapid iteration.
Problem: Sharp corners (especially the "armpit") caused the 3-sensor design to lose the line.
Solution: Added 2 outer sensors and implemented FSM to detect and correct for line loss.
Problem: Initial solderable breadboard made component changes difficult.
Solution: Switched to solderless breadboard for rapid prototyping, then planned PCB for final version.
Problem: Recompiling and re-uploading code for each tuning adjustment was time-consuming.
Solution: Developed Python GUI with serial communication for real-time parameter adjustment.