First Place Solution in Fall 2023 Simulation Racing Series
Written by Mark Menaker, our 2024 ROAR Ambassador from University High School in Irvine.
Table of Contents
The Summer 2023 ROAR S1/S2 Series Challenge is an autonomous racing competition held by the University of California, Berkeley. Competitors use Python to automate a simulated Tesla Model 3 in the virtual Carla research environment, which was developed for the testing of self-driving car algorithms. The competition raced on the Monza Map for the first time in this competition.
My solution was mainly a carryover of my team’s solution (at https://roar.berkeley.edu/second-place-solution-in-summer-2023-simulation-racing-series/) in the last competition from the ROAR code base and Berkeley Major Map to the new ROAR_Py codebase and Monza Map.
Main Changes from Previous Solution
The solution from the previous competition used a very generalized approach, and as a result, changes mainly included removing calculations involving pitch (as Monza is mostly flat), and the removal of slowdown points (as Monza doesn’t have random dips and bumps that required special handling). The code structure was also significantly changed, as there were no longer config files and many different python modules.
General part of solution - carried over from Summer
My main factor in having a fast solution was to make the throttle setting depend on a target
speed instead of on the direction error, which was used by winning solutions in the past. Throttle was previously set based on current speed and 2 direction errors (one to a close point and one to a far point), but we decided to change this. Instead, I used several specifically chosen waypoints ahead to compute the radius of an upcoming turn (the Menger curvature formula was helpful). Using the radius and the formula for centripetal acceleration
I was able to compute the maximum allowable speed by setting max acceleration to
The coefficient of friction was eventually determined through trial and error. Additionally, I divided the track into ten sections of equal length, and the friction coefficient was lowered in some of them to prevent collisions.
From there, I was able to mathematically compute the maximum allowable speed at the current location (since I knew the distance to the start of the turn and how fast the car can decelerate). I repeated this procedure by analyzing the upcoming turn for 3 different distances ahead (0, 30, 60 meters, along with a longer curve through all three distances) which produced 4 speed values. I chose the smallest of the 4 speeds as the safe max allowable speed at the current point.
Knowing the max allowable speed enabled me to fine-tune my settings for throttle and brake.
After trying several strategies, I settled on the following. If the current speed was over the max allowable speed by a certain amount, I applied full brakes, but if it was under, I kept full throttle. If the current speed was within a few % of allowable speed I would use less-than-full throttle with a goal of maintaining speed without overshooting too far.
Steering was similar to that of the Summer Competition, where it was based on Aaron Xie’s winning solution in Spring 2023. Small adjustments were made to account for changed orientation of x, y, z axes, and to statically initialize steering parameters (instead of reading them from a file).
Generating Racing Line
I used a strategy of waypoint averaging to generate a more smooth racing line. When getting waypoints for steering and speed calculations, the planner didn’t rely on a single lookahead point. Instead, it took a series of waypoints ahead and behind the lookahead point (the number was based on which part of the track) and found an average waypoint. This allowed the car to come closer to the inside of the corners and have a longer turn with larger radius, enabling higher speed. In order to avoid hitting the wall, I limited the distance that the new point could be shifted from the old one by introducing a max_shift_distance which varied in different sections.
Thank you very much Dr. Allen Yang and your team of experts for ROAR Academy, and all the
effort put into running the competition. The office hours were a great help to get started with the
new map and code base. I enjoyed participating in the summer and fall competitions and found them to be valuable learning experiences to expand my knowledge and skills.