eckhchri / pcars-ds-liveview

Provides a html page for project cars dedicated server and display a map of the current race.
14 stars 1 forks source link

Calculate time gaps between drivers during race. #114

Closed viper4gh closed 6 years ago

viper4gh commented 6 years ago

During a race the time gap between drivers is a relevant information. But it is not available in the DS data. The only way is to calculate it. The idea is to sum up the lastlaptime for every driver, if he is crossing the start/finish line and then calculate the diff to the driver ahead and the driver in front. The Requirement for this is, that liveview receives data since the beginning of a race and over the complete time without outages. And unfortunately the gap is calculated one time per laponly, every time when a driver is crossing the start/finish line.

viper4gh commented 6 years ago

Next steps:

viper4gh commented 6 years ago

Race Gaps are working now one time per lap. Next step is to evaluate the possibilty to update it after every sector.

Attention: If a race is finished the lap counter is the last time increased by 1 and the gaps are calculated correct, because the calculate trigger is then activated the last time. If the sector times are still be updated in the cooldown lap, then these must not be included in the calculation anymore.

viper4gh commented 6 years ago

The described "Attention" in the comment above is no problem, because the Sector is changed to 0 after a driver finished his race and stays 0. That means the trigger on the changes from sector 1 to 2 and 2 to 3 are never fired again.

viper4gh commented 6 years ago

Record a longer Race where a driver ahead has 2 laps lead for checking if the LapDiff logic is working correct in this case.

viper4gh commented 6 years ago

There is a small problem if a car overtakes another at the moment when they drive from one to another sector. The sum of the lap- and sector-times of the new leader is higher than the sum of the second. Example of a record exactly after two drivers cross the sector line from 2 to 3 in the second lap: Pos 16: 106449 ms Pos 17: 106426 ms If I would use the time sum only Pos 17 must be before pos 16. As result Pos 16 has a higher gap to the race leader as Pos 17 and the diff between 16 and 17 is negative and then the Driver Table shows "-" for Pos 17.

There is not much what I can do, it seems to be a timing problem in the DS API. The moment when the cars cross a sector line and the moment when the times are measured. In this case the time is measured a moment before, which means before the overtaking maneuver has happen.

Furthermore, the gaps are corrected when the cars cross the next sector line.

viper4gh commented 6 years ago

Calculation implemented -> Close Issue