Race to Perfection

Engineering Optimal Racepaths for Autonomous Racecars


Here’s a look at UVA’s Cavalier Autonomous Racing car (in orange) as it overtakes an opposing car at a recent Las Vegas race.
Here’s a look at UVA’s Cavalier Autonomous Racing car (in orange)
as it overtakes an opposing car at a recent Las Vegas race.


Welcome to the exciting world of the Cavalier Autonomous Racing team! Here, we develop race cars that race by themselves. One of our main tasks is figuring out the best route for these cars to follow on a racetrack to maximize speed and safety.

In this blog, I’ll take you through the fascinating process we use to design these routes. We’ll explore how we create, refine, and evaluate the paths to ensure our car can navigate the track both swiftly and safely. The illustrations below are based on data from our practice sessions at the Indianapolis Motor Speedway, where later this year, our car will be zooming past competitors at speeds exceeding 160mph.

But first, let’s talk about setting up the racetrack in our systems. Let’s start by defining what’s known as the “track bounds,” which are the edges of the racetrack. Below, you’ll find a map showing these boundaries at the Indianapolis Motor Speedway, marked using GPS coordinates. It’s crucial for our racecar to understand these limits to stay on the right course.




While GPS is a go-to tool for mapping racetracks, it can have bad precision at times. Even small errors can cause big problems for our autonomous racecar. A discrepancy of 10 centimeters might seem small, but it can cause significant navigation errors. And make our racecar stray from its intended course, impacting both safety and performance.

To address this, we focus heavily on enhancing the accuracy of our GPS data. Below, you can see a 3d histogram that illustrates the variations between our GPS readings and the true boundaries of the racetrack. This plot helps us understand how much our GPS data deviates from reality, measured in meters, and guides us in making necessary corrections.



The plot above confirms that our GPS is generally centered around 0, but the variability is problematic, showing a lack of precision. To mitigate this issue, we use smoothing techniques to refine our track bounds data. Smoothing helps create a less erratic driving path, avoiding steering errors that might cause the car to zig-zag.

Next, we’ll test some smoothing techniques. In the upcoming visualization, you’ll see data represented in terms of ‘change in heading’, which is measured in radians. This represents how much the steering direction needs to be adjusted when driving along the track edge. The gray lines show the steering adjustments based on the original, unsmoothed GPS data. The colored lines show the steering adjustments after applying different smoothing techniques. This will help us assess which method produces a more stable and reliable driving path for the racecar. Remember, the shakier the lines on the graph are, the more unstable and shaky the car will be on the race track.




The comparison clearly shows that the smoothed bounds result in a much steadier path than the original, jagged track bounds. This smoother trajectory translates to reduced “zig-zagging” for the racecar, allowing for more efficient and stable navigation on the track. From our analysis, Gaussian smoothing seems like the most effective technique, with Savitzky-Golay also presenting a viable option.

Both of these smoothing techniques come with adjustable parameters that can further refine the smoothness of the track bounds. We can make our track bounds even smoother by fine-tuning these parameters. I have provided a Shiny app below, which allows you to help me tune these parameters. Help me experiment with this tool to find the smoothing parameters that yield the smoothest lines.


Click Here:
Smoothing Dashboard



Screenshot of Smooth App.
Screenshot of Smooth App.



Great work on selecting the best settings for our smoothing techniques! With smoother track boundaries in place, we’re ready for the next exciting phase: creating racelines.

Creating racelines is a detailed and iterative process. This process involves continuously refining a proposed racing path, making it less curved with each step. This helps the car move faster and more efficiently around the track because a minimaly curved path allows for better speed and control.

Below, you’ll see an animation that shows a few steps of this process. It’s a simple demonstration, but in reality, our algorithm runs through thousands of these adjustments to find the perfect raceline. Each iteration fine-tunes the path to get as close as possible to the ideal route that minimizes travel time and maximizes safety during the race. Pay attention to the color (velocity) of the track as it gets fine-tuned.



Now that we have crafted an initial raceline, the next step is to ensure it is safe for high-speed racing. Our racelines aim to utilize as much of the track as possible, which often means getting very close to the track walls at the Indianapolis Motor Speedway. However, to accommodate any potential errors, it’s crucial to establish a safety buffer.

This safety buffer keeps our raceline a safe distance from the walls, preventing collisions due to errors in navigation. Yet, it’s important not to set this buffer too wide. If we’re too conservative and stay too far from the walls, we’ll slow down the racecar, losing valuable speed.

To find the right balance between speed and safety, I made a tool that allows you to adjust the distance from the track’s left and right boundaries interactively. Below is a Shiny app where you can experiment with different settings for this safety buffer. By adjusting these parameters, you can see how changes affect the racecar’s speed and safety, helping me find the optimal compromise.


Click Here:
Raceline Dashboard



Screenshot of Raceline App.
Screenshot of Raceline App.



Fantastic! We’ve successfully selected a raceline that balances speed and safety effectively. Now, let’s see how this choice performs in real-time conditions.

The upcoming animation will display our racecar in real-time as it navigates the Indianapolis Motor Speedway, which is 2.5 miles long. You’ll notice a gradient trail that changes color according to the car’s velocity. Watch how the car behaves and observe the effectiveness of our raceline!

This plot compares the expected lap time of our autonomous racecar—51.299 seconds—with recent performances at the Indy500. Our vehicle is modeled after a standard Indycar, but there are several key differences to note. Firstly, our racecar operates autonomously, so instead of a drivers seat, we have computers and sensors. Additionally, our simulations are conducted with the car racing solo on the track, which differs significantly real racing with multiple competitors. While the direct comparison of lap times provides a useful benchmark for evaluating our raceline, keep note that this isn’t a “fair” comparison.





As we wrap up this blog, it’s exciting to see that our autonomous racecar is not just keeping up but even slightly outpacing the average lap times of Indycar drivers at the 2023 Indy500! This is a big step for autonomous racing, showing that the technology we’re developing could really change the way races are run in the future. But mastering the perfect raceline is just the start. The next big challenge we face is figuring out how to make our car smart enough to safely overtake other cars on the track. This involves creating algorithms that help the car make quick decisions and react to what other cars are doing. Plus, we need to ensure our car can handle different track conditions and unexpected situations. As we continue to improve and test our technology, we’re excited about the possibilities it opens up. Thanks for riding along!