A GGV Iterator
What is it?
GiGi is a "GGV iterator", that is, an iterative algorithm which alternates a point-mass "GGV" model forward and backward over a curvature array, finding speed, longitudinal and lateral acceleration signals. It comes with heuristic trajectory optimization routines.
How is it built?
It is a classic, flat-track GGV iterator, with a core solver in C++ and ancillary functions and interfaces in Python.
It needs two basic elements to work:
- A point-mass GGV model
- A curvature signal
The point-mass GGV can be either defined from some basic parameters (vehicle mass, max power, aerodynamic resistance and lift coefficients, longitudinal and lateral grip) or imported from a full JacoBike representation, which will get evaluated at N speeds and then interpolated by the solver through splines. Whatever the definition, the GGV model must be able to evaluate, at any speed, the maximum lateral acceleration that it can produce, and, for a given speed and lateral acceleration, the maximum and minimum longitudinal accelerations achievable.
The curvature signal can be extracted from a trajectory, described as a collection of (x, y) data points. This can either come from a GPS sampling of a real vehicle along a track, from its geometrical definition, or from "racing line optimization" of a Track.
First, the GGV model is interrogated for each step of the curvature-over-distance array. For each curvature, the maximum achievable speed of the vehicle is determined: this will act as an initial lower bound for the speed estimation.
Second, the algorithm iterates back-and-forth along the curvature signal, and it selects the minimum speed between the curvature-constrained one and the maximum achievable in full acceleration from the previous point, or in full braking from the following one.
Once it has gone through a full forward and backward iteration without changing any speed value, the algorithm recognize convergence, and it will return a speed history, which longitudinal and lateral acceleration can be extracted from.
If the GGV was exported from a JacoBike object, then its parent can be used to reverse equilibrium equations, finding, for each point along the time history, the status of controls (gas, brake, steering wheel position, gear if available). This gives an initial, fast approximation of a vehicle's performance on a track.
What can it do?
Through the use of a simplified GUI, it can be used to load F1 telemetry data (from TracingInsights repository) and manually correlated a simplified model by trying and matching the speed, longitudinal and lateral acceleration signals. The same approach, though with the genetic algorithm and through the definition of a more rigorous fitness function, can be automated, allowing me to "fit" a GGV model from a known telemetry source.
The same genetic algorithm, natively running in C++, can be used to heuristically determine the best racing line for a given vehicle and track. In this procedure, we assume the vehicle's characteristics to be known, but we aim to determine the line along the track that ensures the lowest possible lap time. To do this, we introduce a "Track" object, consisting of a series of segments going from the left margin to the right one; we describe the position of the vehicle along the track as a sequence of normalized coordinates between left and right margin, and, for each combination, we extract the resulting trajectory and use the iterator to find the lap time.
This might seem arbitrary and a bit "academic", but it does work, or at least it did for me: I was able to lower my record on the local karting track by more than 1 second after following the optimizer's line suggestion.
Interestingly enough, different vehicles or set-ups optimized over a same track may result into very different trajectories, even accepting the extreme limitations of this kind of model.
Coupled with the JacoBike editor, the iterator can be used to get a complete picture of a vehicle's control, stability and actual performance over a given track. The process can be used to optimize the aero set-up and gear ratios (accounting for different tire characteristics, for example).
Where is it going?
GiGi is currently missing all altitude information, which is of obvious importance in correctly determining laptime: this is the first step in which improvements need to be directed.