Apps How to get correct driven distance in python apps, taking into account jumping behind the start/finish line in "back to pits"?

I'm doing yet another leaderboard-gap-distance, etc. app, and I'm collecting all kinds of data of car's position on track and distance/time history etc.

In general, just doing ac.getCarState(carID, acsys.CS.LapCount) + ac.getCarState(carID, acsys.CS.NormalizedSplinePosition)
gives a nice number that denotes the distance the car has driven in the race. However, this doesn't work if the car jumps back to pits and their pit box is behind the starting line: If the car driven 2 laps and is currently in spline position 0.20, and jump back to their pit box which is at spline position 0.99, the lap count remains the same and it looks like they have jumped forward in the track while they have actually jumped backward.

Now I could of crouse try to detect sudden jumps and keep track of the corrections, but it is an ugly hack and sounds like a recipe for disasters in some edge cases or connection problems in online races.

Is there any way in the API to distinguish between "Car has driven 2 laps and 99 % of the current lap and is about to finish the 3rd lap" and "Car has driven 2 laps and is currently 1 % behind the starting line but is not about to finish the 3rd lap". ? I can't find an answer in either the Python API doc or the shared memory doc.
 
Last edited:

Latest News

Are you buying car setups?

  • Yes

  • No


Results are only viewable after voting.
Back
Top