s-victor / TinyPedal

Free and Open Source telemetry overlay application for racing simulation
GNU General Public License v3.0
75 stars 8 forks source link

Relative widget lapped drivers color #35

Closed alexbrrsclnt closed 10 months ago

alexbrrsclnt commented 10 months ago

Hi, Since some days ago I am racing in the new ranked events of rFactor2 using Tinypedal to aid with in game data.

I have detected a few times that in the relative widget, the text color of the drivers that are being lapped not always is using the blue color assigned. And when you are lapped, sometimes the leaders text color is not using the purple color.

Don't know if it is a tinypedal issue or a problem that the plugin is giving wrong data.

Thanks!

s-victor commented 10 months ago

Hi,

Is it race session or none-race session?

Since lap difference color from font_color_laps_ahead & font_color_laps_behind option only affects race session as noted in user guide. In none-race session lapped color will not shown (such as practice, qualifying, warmup) , this is done in the same way as how in-game system treats blue flag in practice or qualifying session. For example, you don't get blue flag because opponents did more laps in practice, otherwise there will be always full blue or purple on opponents.

However, if lapped color did not correctly shown in race session, it could be a bug. If it is race session that you have had this issue, please let me know. (also make sure tinypedal spectate mode is not enabled)

Thanks.

alexbrrsclnt commented 10 months ago

Yeah, It was always in race sessions, and spectate mode was disabled

s-victor commented 10 months ago

Thanks, I will need more information (or reproducible steps) to identify the issue, as currently my network is poor and can't test in multiplayer.

Some details like following would be helpful:

s-victor commented 10 months ago

Hi, I just recalled that certain tracks would return negative player on-track distance value when near or passing pit lane, which requires to restrict reading in positive value only.

This was done on session widget percentage lap number calculation, but was forgotten on vehicles module (that feeding lap number & distance data to relative widget). So it possible that on certain track a negative distance value caused wrong lap number calculation. (There were a few posts on official forum also mentioned some related issues).

Here is a new commit with the fix https://github.com/s-victor/TinyPedal/commit/125f0f05fc70ac70c0355e14f8db8b3e22f40b53

alexbrrsclnt commented 10 months ago

Thanks, I will update my installation and will record my next few races to check if I detect something again.

alexbrrsclnt commented 10 months ago

I have updated my installation to the last master commit and TinyPedal is not working properly. If I launch it from terminal the following errors show in log. Traceback (most recent call last): File "/home/alex/git/github/s-victor_TinyPedal/tinypedal/widget/radar.py", line 77, in update_data if self.wcfg["enable"] and read_data.state(): File "/home/alex/git/github/s-victor_TinyPedal/tinypedal/readapi.py", line 63, in state return not info.paused and info.rf2TeleVeh().mIgnitionStarter AttributeError: 'SimInfoSync' object has no attribute 'rf2TeleVeh'. Did you mean: 'rf2Tele'? Traceback (most recent call last): File "/home/alex/git/github/s-victor_TinyPedal/tinypedal/widget/sectors.py", line 171, in update_data if self.wcfg["enable"] and read_data.state() and minfo.sectors.SectorPrev: File "/home/alex/git/github/s-victor_TinyPedal/tinypedal/readapi.py", line 63, in state return not info.paused and info.rf2TeleVeh().mIgnitionStarter AttributeError: 'SimInfoSync' object has no attribute 'rf2TeleVeh'. Did you mean: 'rf2Tele'? Traceback (most recent call last): File "/home/alex/git/github/s-victor_TinyPedal/tinypedal/widget/speedometer.py", line 156, in update_data if self.wcfg["enable"] and read_data.state(): File "/home/alex/git/github/s-victor_TinyPedal/tinypedal/readapi.py", line 63, in state return not info.paused and info.rf2TeleVeh().mIgnitionStarter AttributeError: 'SimInfoSync' object has no attribute 'rf2TeleVeh'. Did you mean: 'rf2Tele'? Traceback (most recent call last): File "/home/alex/git/github/s-victor_TinyPedal/tinypedal/widget/timing.py", line 183, in update_data if self.wcfg["enable"] and read_data.state(): File "/home/alex/git/github/s-victor_TinyPedal/tinypedal/readapi.py", line 63, in state return not info.paused and info.rf2TeleVeh().mIgnitionStarter AttributeError: 'SimInfoSync' object has no attribute 'rf2TeleVeh'. Did you mean: 'rf2Tele'? Traceback (most recent call last): File "/home/alex/git/github/s-victor_TinyPedal/tinypedal/widget/flag.py", line 202, in update_data if self.wcfg["enable"] and read_data.state(): File "/home/alex/git/github/s-victor_TinyPedal/tinypedal/readapi.py", line 63, in state return not info.paused and info.rf2TeleVeh().mIgnitionStarter AttributeError: 'SimInfoSync' object has no attribute 'rf2TeleVeh'. Did you mean: 'rf2Tele'?

alexbrrsclnt commented 10 months ago

I have reverted to v2.2.0 and check in race session that the issue is that the lapped driver text font color only changes to blue after you pass him. In some other relatives, the drivers that are going to lose a lap, or the leaders that are going to pass you are displayed in the relative with the color already corrected before they change position with you, maybe to be able to differenciate them from drivers in your current lap.

I had that situation in my last race but I messed up the OBS recording so I cannot show you the proof, but that is what's going on. Don't know if this is something that can be corrected in TinyPedal.

Edit: In this video in the top right corner of the screen the relative widget is barely visible, but the radar helps to show the change of color of lapped drivers after they are behind.

Relative widget video

s-victor commented 10 months ago

Thank you very much for the testing feedback & video, though I cannot watch video because most video websites is region-blocked here. I'll try address some of the issues you mentioned.

I have updated my installation to the last master commit and TinyPedal is not working properly.

The latest commits contains update to pyRfactor2SharedMemory submodule. Make sure you have pulled changes from pyRfactor2SharedMemory submodule. You can do this by go into pyRfactor2SharedMemory folder and run cmd: git pull origin master. Then go back to main folder and install it again(if you run tinypedal from installation). I have tested latest commits on KDE and all works ok.

the issue is that the lapped driver text font color only changes to blue after you pass him. In some other relatives, the drivers that are going to lose a lap, or the leaders that are going to pass you are displayed in the relative with the color already corrected before they change position with you, maybe to be able to differenciate them from drivers in your current lap.

The lap ahead/behind color indicator only shows lap difference (greater than 1 lap) that is already established. This lap difference is calculated in actual lap distance between player & target opponent, so the difference is accurate no matter which part of track vehicles is at.

For example, if a slow car is currently 0.99 lap difference behind you(which will be a few meters in front of you on circular track), the slow car will not become blue color until you passed him (which then he will be 1+ lap different). If this is the case as you have described, then it is working as intended, since lap ahead/behind color is for lap difference indication, not for blue flag indication. Same goes for leader, they only become purple color if lap difference is greater than 1.

However, I could revise the code to make it so that at for example at 0.9 lap difference, it will trigger blue color on slow car behind, or purple on fast car ahead, if needed.

In the latest commits, I have added workaround for earlier mentioned potential issue with negative distance reading from API, so that incorrect lap difference should no longer occur.

For reference, the lap difference is calculated from following formula (since game API doesn't give accurate lap difference directly): https://github.com/s-victor/TinyPedal/blob/master/tinypedal/calculation.py#L197 which can be broken down to: opponent total lap completion(with decimal places) = opponent completed lap number(int) + opponent current lap percentage completion player total lap completion(with decimal places) = player completed lap number(int) + player current lap percentage completion final accurate lap difference = opponent total lap completion - player total lap completion

And current lap percentage completion is calculated from formula: https://github.com/s-victor/TinyPedal/blob/master/tinypedal/calculation.py#L178 https://github.com/s-victor/TinyPedal/blob/master/tinypedal/module/module_vehicles.py#L190 which is calculated from: current lap vehicle traveled distance / total track distance(length) and the value is now restricted in 0 to 0.99999 in latest commits.

Note, there is still a potential 200ms desync issue when crossing finishing line, as raw lap number & raw lap distance value does not always sync at the moment of crossing finish line. For example, when the moment crossing finishing line, raw lap number could be updated from 3 laps to 4 laps, but current lap vehicle traveled distance could still be at 1.0 due to 200ms API update delay, so when the calculation adds them together, the results will be 4+1 laps instead of 4+0 laps. This desync can also happen backwards. The good thing is that even if it happens, it will be synced again after 200ms as the result of game API hard-coded 5fps(200ms) scoring data refresh rate.

As far as formula & calculation concern, I can't find further issue. Please lemme know if anything is incorrect in the calculation .

There is however a chance that the current RC-build of game may have bug. There was a few bug report on game forum mentioned that leader's laps were not counting due to cut detection BUG, such as in this post. So there is chance that it is issue from game.

There are also some known limitation in game API. One common issue is that some data from API do not always sync & stay up to date with game, such as tyre compound & pit counts & pit time, which would not update until several laps later(this happens a lot in our league races).

alexbrrsclnt commented 10 months ago

Oh, I forgot to also update the submodule. I will do, test again and report back.

Thanks!

s-victor commented 10 months ago

I'm closing this now due to lack of info and ways to reproduce the problem. Free feel to open again if there is further issue related, thanks.

Edit: just added lap difference threshold options (as mentioned earlier) in Vehicles module here https://github.com/s-victor/TinyPedal/commit/268d5725e505bdc838e781c2bba683acb8ab30d6 , now you can set ahead and behind lap threshold in percentage, so you can see whether opponents is about to lap or being lapped. Default values are 0.9.