ErlerPhilipp / dr2_logger

A logging and analysis tool for Dirt Rally 2.0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

linux usage tips

fenugrec opened this issue · comments

Hi,
I'm happy to report this can be used mostly as-is on linux (Dirt Rally only of course, v2 is not available). I'd like to suggest a few improvements to make it easier to use :

  • add a note to the README: the file hardware_settings_config.xml is actually stored in
    ~/.local/share/feral-interactive/DiRT Rally/VFS/User/AppData/Roaming/My Games/DiRT Rally/hardwaresettings/
    There is also an unused / useless copy of that file in
    ~/.steam/steam/steamapps/common/DiRT Rally/share/data/system/
    which seemed to be totally ignored ? UDP needs to be enabled in the first file !

  • I manually installed some missing dependencies (numpy etc) via my distro's package manager, nothing special but not quite plug&play. No big deal. I didn't try conda.

  • at https://github.com/ErlerPhilipp/dr2_logger/blob/master/dr2logger.py#L108 , I had to remove the line
    ctypes.windll.kernel32.SetConsoleTitleW(state_str)
    obviously, windll != linux. python is really not my bag so I have no alternative to suggest here; I just disabled the whole "if" block. There's probably a cleaner method.

  • so far the rest seems to work ok. Cool !

Also works with Dirt Rally 2.0 through Proton (telemetry is provided via UDP just the same) after dealing with the windll bit.

Thanks a lot for your feedback. I didn't even know that it's available for Linux.

@jotomo with "just the same", you mean the same directory as that fenugrec wrote?

@fenugrec about the package manager: which one are you using? is a requirements.txt sufficient?

@fenugrec i'm sure the linux libraries have a similar function to set the terminal's window title. i can add this or at least remove the missing call.

@fenugrec since you're using the logger for DR1, should i add a car and track detection like for DR2 and add a flag for DR1 in the settings? or do you think, no one cares?

@fenugrec about the package manager: which one are you using? is a requirements.txt sufficient?

requirements.txt was sufficient for me, on Arch linux the distro package manager is "pacman" and there are pre-compiled packages for those dependencies. Didn't need to mess with pip or other garbage. Other distros may vary

@fenugrec i'm sure the linux libraries have a similar function to set the terminal's window title.

I did a non-exhaustive search and came up with https://stackoverflow.com/a/47262154 . "works here", may not work on some terminals but should do no harm.

@fenugrec since you're using the logger for DR1, should i add a car and track detection

hmm, I haven't been using this very long, but it seems the track is detected already (at least in some cases). Car detection would be nice if it's not tons of extra work. Might be possible to reuse data from dirt-rally-time-recorder, e.g. https://github.com/soong-construction/dirt-rally-time-recorder/blob/master/resources/setup-dr1.sql [EDIT] haha, just noticed you already have that data in dr1specific.py , so maybe I misunderstood your question ?

Note, there are ambiguous car definitions and may need an extra prompt to ask the user to clarify.

@ErlerPhilipp

with "just the same", you mean the same directory as that fenugrec wrote?

I meant that from the point of view of dr2_logger, it doesn't matter that DR2 isn't natively available on Linux but runs through Proton since dr2_logger uses a network connection to receive the telemetry data from DR1/2 and is thus oblivious to whether DR1/2 runs on Windows, natively on Linux or via Proton.

Running DR2 via proton the hardware configuration ends up at:
~/.local/share/Steam/steamapps/compatdata/690790/pfx/drive_c/users/steamuser/My Documents/My Games/DiRT Rally 2.0/hardwaresettings/hardware_settings_config.xml

requirements.txt was sufficient for me, on Arch linux the distro package manager is "pacman" and there are pre-compiled packages for those dependencies. Didn't need to mess with pip or other garbage. Other distros may vary

I'll update the requirements.txt and keep it up-to-date. together with the yml, this should be sufficient for most Python users.

I did a non-exhaustive search and came up with https://stackoverflow.com/a/47262154 . "works here", may not work on some terminals but should do no harm.

I'll try this and keep it in try...except to prevent any crashes. Would be great, if you could test it when it's ready. I don't have a Linux machine available at the moment.

hmm, I haven't been using this very long, but it seems the track is detected already (at least in some cases). Car detection would be nice if it's not tons of extra work. Might be possible to reuse data from dirt-rally-time-recorder, e.g. https://github.com/soong-construction/dirt-rally-time-recorder/blob/master/resources/setup-dr1.sql [EDIT] haha, just noticed you already have that data in dr1specific.py , so maybe I misunderstood your question ?

Track detection works is some cases because the old tracks were (almost unchanged) included in DR2. Most car data is different afaik although they're the same cars. I'm already in contact with one developer of the dirt-rally-time-recorder ;) We exchange ideas and information from time to time. The dr1specific.py is just a place-holder that I never used or tested. Adding support for DR1 requires some effort but I wanted to do it already some time ago. It would be great to add support for e.g. Project Cars 2, too.

Note, there are ambiguous car definitions and may need an extra prompt to ask the user to clarify.

There are a lot of conflicting cars in DR2, too. I'm aware of this issue. The reason is that DR1+2 don't send the car names or some unique identifier, just idle-RPM, max-RPM and number of gears. I'm just not sure if a prompt is a good solution. The logger should run in the background without any inputs between the races. Any ideas are welcome.

I'll add notes for the hardware_settings_config.xml on Linux to the readme. Please check the dev branch for updates in the next few days.

I'll try this and keep it in try...except to prevent any crashes. Would be great, if you could test it

Sure thing.

I'm just not sure if a prompt is a good solution. The logger should run in the background without any inputs between the races. Any ideas are welcome.

But there are already prompts for actions like Clear / analyze / save last run, etc - aren't we supposed to switch to the console after every run anyway ?

But there are already prompts for actions like Clear / analyze / save last run, etc - aren't we supposed to switch to the console after every run anyway ?

you can switch to the console after every run, of course. but you can also do several races and afterwards load the autosaves and analyze them. i could add an optional input after the race to choose the correct car.

@fenugrec @jotomo I have finished the changes and pushed them into the dev branch.

  • added the settings paths to the readme
  • added (hopefully working) set title for linux, at least it shouldn't crash anymore
  • added a setting to switch between Dirt Rally 1 and 2 (either enter 'Dirt_Rally_1' in the 'game' variable in the settings.ini or use the command 'g Dirt_Rally_1' when the logger runs
  • added car and track detection for DR 1
  • the requirements.txt is now up-to-date and contains the exact package versions. This should work e.g. with 'pip install -r requirements.txt'

This was a major re-structuring. Now, it won't be too much effort to add support for e.g. Project Cars 2 :)

I currently don't have Linux or DR1 installed, so please test it.
RX cars for DR1 are currently missing, so please send me the 'unknown cars.txt' with the corrected car names.

Does it work for you?

Awesome ! will check it out next time I'm in DR within 1-2 days.

@ErlerPhilipp Thanks for the work you put into this project!
I've tested the dev branch. conda and pip install don't work for me (pip fails to find some packages and conda is confused about paths) but that's probably something specific to Arch or my installation (need to do some housekeeping and fix sudo sins I've committed over the last 8 years).
With manually installed deps, just running logger_frontend.py works. Terminal-title is not updated but Race starting and Race finished are printed, which is enough for me. I played around with writing control sequences to stdout, but that didn't change the title either, so it's probably not supported in my terminal (KDE's konsole).
In short: works :-) README still refers to dr2logger.py instead of logger_frontend.py, but I assume that's queued for polishing before a release.

* set title for linux, at least it shouldn't crash anymore

Yep, "works here" (urxvt console)

This was a major re-structuring.

I noticed ! nice work.

send me the 'unknown cars.txt' with the corrected car names.

I assume you'd need the tracks too ?
cars

[7330.38330078125, 1466.0714721679688, 4.0, 'Mini Classic Rallycross'],
[9686.577758789062, 1989.6754455566406, 6.0, 'Opel Corsa Super 1600'],
[9686.577758789062, 1989.6754455566406, 6.0, 'Rnault Clio S1600'],
[9686.577758789062, 1989.6754455566406, 6.0, 'Peugeot 207 S1600'],
[9110.618896484375, 1413.7167358398438, 6.0, 'DS Automobiles DS3'],
[7853.98193359375, 1727.8750610351562, 6.0, 'Ford Fiesta Rallycross'],
[7853.98193359375, 2617.9940795898438, 6.0, 'Volkswagen Polo Rallycross'],
[8377.58056640625, 1884.9555969238281, 6.0, 'Peugeot 208 WRX'],
[8377.58056640625, 1884.9555969238281, 6.0, 'Mini Countryman Rallycross'],
[7853.98193359375, 2094.3939208984375, 6.0, 'Subaru WRX STI'],

tracks, these were a bit weird (second number varies with different cars ?

[1348.85400390625, 96.47221374511719, 'England Full'],
[1036.0970458984375, 125.0980453491211, Norway Full'],
[1207.18798828125, 173.65447998046875, 'Sweden Full'],
[575.1746215820312, 96.56448364257812, 'England Junior'],
[985.9498901367188, 125.1002197265625, 'Norway Clubman'],
[682.9323120117188, -66.44092559814453, 'Sweden Junior'],
[989.7551879882812, 96.58692169189453, 'England Clubman'],
[936.9108276367188, 173.6415557861328, 'Sweden Clubman'],

@jotomo

conda and pip install don't work for me (pip fails to find some packages and conda is confused about paths)

turns out some package names are different in pip and conda. i pushed an updated requirements.txt to the dev branch. now, it works for me with 'pip install -r requirements.txt'. Conda's path confusion seems strange. i can't imagine that i have an influence there.

so it's probably not supported in my terminal (KDE's konsole)

the KDE terminal seems a bit special. i found this: https://stackoverflow.com/questions/19897787/change-konsole-tab-title-from-command-line-and-make-it-persistent
does this help? did you try the version with "\033]30;test change title\007"? maybe, the '30;' means something.

README still refers to dr2logger.py instead of logger_frontend.py, but I assume that's queued for polishing before a release.

yes, the readme needs some polishing. there are a few minor things that i need to add before the next release. e.g. i switched the car detection to raw data meaning that the x10 factor for RPM is not stored anymore but applied on-the-fly when plotting. so, i should add a version field to the saved runs.

@fenugrec

I assume you'd need the tracks too ?

yes, thanks a lot. i added the data and pushed it to the dev branch. please test again, there might be a rounding error caused by the x10 RPM factor.

tracks, these were a bit weird (second number varies with different cars ?

that's ok and necessary (unfortunately). the first number is the track length. it's the only information about the tracks that i get from DR. the second number is basically the spawn position of your car. it varies a bit but is sufficient to separate forward and reverse versions of tracks (where the track length is sometimes exactly the same).

@ErlerPhilipp
Konsole: works somewhat with the SO answer you found, see comments: cba01d0
Checking the active desktop environment isn't useful as users may use any terminal with any DE and checking the TERM env var isn't helpful either (see commit). Supporting all terminals in Linux is hackish, since there doesn't seem to be any standard or interface. This is probably not worth the effort, IMO. When racing I have only one monitor/TV switched on (performance is reduced if I leave all 4 on), so personally I don't need the title to be updated during a race.
requirements.txt: thanks, pip works here too now
Conda:

$ conda env create --file dr2logger.yml
Collecting package metadata (repodata.json): failed

NotWritableError: The current user does not have write permissions to a required path.
path: /usr/pkgs/urls.txt
uid: 1000
gid: 100

Some env var expected that's not expanding after /usr? Anyways, should be local to my system and pip works just fine.

P.S. also tested with urvxt under KDE, there the title is updating throughout the race.

@jotomo
Thanks for testing! I'll include your snippet.
About the write permissions of conda: This error feels familiar. If I remember correctly, I had the same error a while ago. The reason was that I installed anaconda in a wrong directory. conda needs the rights to write into the env directory.

@fenugrec @jotomo
I just released version 1.8 with this and many other improvements. Please leave some feedback, e.g. here: Plot Feedback Issue
If you installed the pyinstaller package, you should update it to 3.6 because there seems to be a security vulnerability with older versions.