Second Place Solution in Fall 2023 Simulation Racing Series
Written by Yuehan Yang, Audrey Han, Gavin Chang, Alex Lin, and Brandon Koo from Walnut High School
Table of Contents
In ROAR Fall 2023, competitors have to use Python to autonomously race a car around the new Monza Map. Using the Carla research simulation, we had to develop and test a self-driving car’s capability to traverse the map. Extending on Aaron Xie and Mark Menaker’s team’s solution, we implemented additional programs in order to achieve an accurate and efficient run.
The main strategy we used in the competition consisted of dividing the map into zones along with the use of a speed based gain scheduling PID system. To tune values efficiently, we used graphs to display our target and current to make it easier to adjust PID values. We also experimented with sharp turns to retain speed at turns but it ended up being too inconsistent. As a result, we combined it with Mark Menaker’s team’s past max velocity based turning system to create an overall good self driving agent.
With the aim of being able to control certain parts of the car’s PID during certain parts of the Monza Map, zone’s were utilized in order to solve this problem. Using the coordinate system that was implemented during our attempt to debug, we integrated different zones into our race track. Each zone was aimed to set certain PID values in order to allow our car to run optimally through the entirety of the track.
PID Implementation and Gain Scheduling
After looking at the sample controller code and doing some research, we noticed that the integral and derivative terms were not added to the controller. So we decided to implement the basic PID algorithm for Steering and Throttle into our controller.
error = target_speed – current_speed
Inspired by Aaron’s Xie gain scheduling system, we implemented his gain scheduling system along with another iteration. We implemented another gain scheduling variable based on the current zone of our car. At a straight zone, we adjusted our steer PID to be less aggressive and at a sharp turn, more aggressive.
if zone == 4:
Steer_derivative *= 1.1
elif zone == 3:
Steer_porportional *= 1.2
In order to make tuning our PID controller less tedious and time-consuming, we implemented two graphs during our testing, using PyQt5 along with pyqtgraph to create real-time visualizations. We had both a velocity vs. time and a heading angle+target angle vs. time graph which helped us better locate which specific areas our controller needed to be improved in.
For our max velocity algorithm, we took inspiration from team Initial B’s summer 2023 solution. We utilized the Menger curvature formula to take the location of waypoints and calculate the radius of the curve of the track ahead of our car. We then used this radius to calculate the maximum velocity the car could travel through each turn based on its centripetal acceleration.
max_velocity = np.sqrt(acceleration / 1 / inverse_radius)
Whenever our car surpassed its maximum velocity, we decreased its throttle and increased its brake. This allowed us to maintain higher speeds while traversing turns without losing control and crashing.
We would like to sincerely thank Harris Song for his continuous support as basically a coach for our team while being hands-off on the programming aspects so we can explore ROAR ourselves. Second, we would like to thank Aaron Xie and Dr.Allen Yang for their patience, support, and ideas throughout the season. Third, we would like to thank Tianlun Zhang and Huo Chao Kuan for being very helpful, responsive, and patient throughout the various emails. Lastly, we want to thank all the past competition winners. Without any of them, we would not be where we are today, thank you everyone.