F1 23 gap calculation
Hello everyone, I'm having trouble correctly calculating the GAP of the current lap to the previous lap.
I collected the telemetry data:
Lap time: (Current lap time milliseconds)
Speed: (Current speed km/h)
Lap Distance: (Distance vehicle is around current lap in meters)
Last Lap Time: (Last lap time milliseconds)
Track length: (sector 1 or sector1+sector2 or sector1+sector2+sector3..)
I am calculating with the following formula:
speedMedia = (trackLength/(lapTime/1000))
estimateTime = lapDistance/speedMedia
gap = ((lapTime/1000)-(estimateTime/1000)-(lastLapTime/1000))*1000
Sector1 Test:
Lap time: 18493
Speed: 316
Lap Distance: 1165.7295
Last Lap Time: 17941
Track length: 1167 (Sector1)
Gap: ~ 0.533
Now, vehicle open sector 2:
Test:
Lap time: 18512
Speed: 316
Lap Distance: 1168,0742
Last Lap Time: 56074
Track length: 3113(Sector1+sector2)
Gap: ~ -37.568  ????
This gap (-37.568) is wrong.
Anyone know how to calculate correctly this gap, keep in mind, i don't want you to do my work, but i want to understand all of the formula to calculate correctly.
Any comment, technical article or link is very useful.
Regards
Okay, I haven't done this, so I am just talking from how I would try it first time. And I am aware that it introduces considerable error. I'll use examples from your table lap2 and lap3, at lap3 distance of 8.
Values that are used are lap3time=93, lap3distance=8, lap2time=(66+93)/2=79.5 (as they are closest to lapdistance of 8 on lap2) and this is where error is introduced. So, lap3 would be +0.013 compared to lap2
Another example for laps 2 and 3, from your full table, at lap3distance=100. Values are: lap3time=1148, lap2time=1081. So lap3 would be -0.067.
lap3distance=1002, Values are: lap3time=16019, lap2time=(16565+16591)/2=16578. So lap3 is -0.559
There are for sure better and more precise ways to do it and I am not sure how big is error without comparing it during lap with what game shows. Looking at speed in these laps it should be correct that lap3 is faster, but even with speed in first meters I would expect it to be faster, which it is not as seen in first example.