Autonomous Line-Sensing Racecar
Class Project (Group of 2)
Class: Mechatronics Design Lab (EE 192, UC Berkeley)
Timeline: January 2021- May 2021
Skills used: CAD (Fusion 360), C, Microcontroller programming, Hardware testing (PID tuning), 3D printing
Mechatronics Design Lab is a project class where the whole semester is dedicated to building and programming a race car that can complete a race track autonomously using a line sensor camera inspired by the UC Davis NATCAR competition. Using an existing RC car chassis, I worked with a teammate to develop the software and hardware architecture to achieve an average speed of 2 m/s. I was mainly responsible for programming the control system and conducting hardware testing.
The complete presentation slides can be found here.
Process
Understanding the system and sensors involved
The first half of the class was dedicated to introducing everyone to how to use the ESP32 microcontroller as an embedded system for real-time programming applications that are necessary for mechatronics applications that prioritize the timing of tasks run by every electronic device involved in the system, including the motors (DC motor for throttle and servo motor for steering) and sensors (line sensing and velocity sensing). Programming the interaction between each hardware component with the embedded system in C was split up between myself and my teammate; I focused on the velocity sensing whereas he built the software architecture managing the tasks being performed as well as the line sensing.
Optimizing control
After the main foundation of our embedded system was built, we focused on designing an ideal control setup that used the line camera output as an input to the steering control system to provide our racecar the ability to run autonomously around a racetrack. This involved programming a line-finding algorithm that distinguished between the white tape line of the track from a darker floor color, which my teammate worked on, and fine-tuning a PD controller that ensured stability across the track, which was mainly my responsibility.
3 Key Contributions to the Group
1. Velocity sensing and control programming
2. Fabrication of encoder wheel and sensor mount
3. Conducting physical track runs to fine-tune steering control
Outcomes:
Overall, our final result was satisfactory as expected but could have been improved. On a figure-8 track, we were able to achieve an average speed of 2m/s, and across a step was able to reach 2.5m/s – our target was to reach 3m/s. The steering control was accurate but could have been improved by implementing more robust line-finding and control algorithms to minimize oscillations. This was a challenging yet valuable experience learning about embedded systems as well as experiencing the difficulties of remote collaboration for a hardware-dependent project, given that my teammate and I were collaborating remotely from different locations.