So I want to start off by saying that this project for the time being is still very much under development and I’m not even sure how advanced I want it to get yet, or exactly how much more work I want to put in it.
I wrote some MATLAB code to calculate optimal lap times and optimize racing lines using a Frenet-Serret frame. It allows the import of RaceChrono telemetry data and comparing it directly against the simulated optimal line.
You can give it your vehicle parameters:
- Lateral acceleration
- Longitudinal acceleration (forward)
- Longitudinal deceleration (braking)
- Lateral jerk
- Longitudinal jerk
- Minimum turning radius
In the figure above the limits for these parameters were taken from the racechrono log, that way the optimization algorithm creates a perfect lap for similar vehicle dynamics. The logged lap is my 12.09 world record T-race lap for comparison.
After the constraints are set it generates the optimal racing line for the programmed track. Trying to keep the vehicle on one of the above mentioned limits all the time. At the moment I only have the T-race track implemented, as the reason why I even got started on this project is that I was wondering what the optimal lap of T-race actually is, and where I might be able to find more improvements.
You can find the project on github if you want to run it for yourself:
It is being developed in Matlab R2026a, don’t know whether it works in other versions.
It is possible to implement custom tracks, however only T-race is tested to converge for now. For the time being there’s a limitation of ~100-150 nodes per lap due to the solver that’s currently in use, which in practice doesn’t allow the precision required for complex tracks. I want to put in a bit more work on that front and see if I can get good results with another solver that can handle more nodes.
