1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

rFactorSharedMemoryMap.dll

Discussion in 'Automobilista - Links & Resources' started by gongo, May 9, 2016.

  1. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    EDIT: Plugin updated to add missing acceleration and rotation vectors to vehicle scoring info struct.

    I've written a very basic memory mapped telemetry export plugin for AMS (haven't tested it with SCE, but I'm confident it should work there too).
    You can find the DLL available for download at Release 1.1.0.0 · dallongo/rFactorSharedMemoryMap · GitHub

    The telemetry and scoring structs are exported to a shared memory mapped file handle and can be accessed the same way that is done for R3E and AC at the moment. The benefit is that now you can use any programming language you like to access the data. I've written an example in Python that drives the SRD-9c display (GitHub - dallongo/pySRD9c: Python interface for sim racing dashboard display) It's all available at my github repo: GitHub - dallongo/rFactorSharedMemoryMap: Memory mapped telemetry export for rFactor 1

    The struct is defined in rfSharedStruct.hpp along with the name of the handle tag you'll need to access. I've tested the required values for a working dashboard (RPMs, speed, temps, lap and sector timing, etc.) and everything appears to be in working order.

    Also, please note that the speed value is calculated in meters/second.

    Thanks, and enjoy!
     
    Last edited: May 10, 2016
    • Like Like x 3
  2. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    Updated first post, will be making some slight additions to the vehicle scoring info objects tonight.
     
  3. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    @Renato Simioni I'm not finding any info for DRS/boost activation. Is it available hiding in one of the mExpansion byte arrays?
     
  4. DAU Racer

    DAU Racer New Member

    Joined:
    Mar 17, 2016
    Messages:
    7
    Likes Received:
    0
    I actually started doing something like this as well, but unfortunately this kind of things have very low priority in my life, that's why I have something that working but crashing AMS from time to time (I assume).

    One question, why are you assigning variables manually but instead copy the complete data segements with a memcpy (or the related save variant) into the shared memory segment?
     
  5. Dave Stephenson

    Dave Stephenson Administrator Staff Member

    Joined:
    Feb 13, 2016
    Messages:
    132
    Likes Received:
    131
    Probably a better question for @Marcel Offermans
     
    • Like Like x 1
  6. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    I'm not using a direct memory copy because I've changed the byte alignment to 1 for tightest packing. I believe the default pack setting is 4 or 8 (it's been a while since I last used Visual Studio).
     
  7. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    EDIT: I'm an idiot, of course I need the orientation matrix interpolation working for the interpolated position to be anywhere near usable.

    TO DO:
    - Zero out scoring at the beginning and end of each session
    - Put 'time() - currentET' in deltaTime (it's the plugin/frame time right now)
    - Position, velocity, rotation, orientation interpolation for vehicle scoring info.(uninterpolated values when deltaTime == 0)

    WISH LIST:
    - DRS activation info
    - Pit speed limiter activation info
    - Track session best lap/sector times
     
    Last edited: May 10, 2016
    • Agree Agree x 1
    • Winner Winner x 1
  8. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    (can't seem to edit the first post anymore)

    All items on "TO DO" list complete!

    New release v2.0.0.0! Get it here: Release 2.0.0.0 · dallongo/rFactorSharedMemoryMap · GitHub

    What's new:
    Interpolated scoring data! The opponent positions are part of the scoring data and only updated every 0.5 seconds. I've now implemented interpolation with a reasonable amount of accuracy. The math should be correct and the telemetry analysis tool that I'm using shows that the interpolated values are actually quite good.

    I'm ignoring localAccel and localRotAccel for the time being since those only seemed to make the interpolation worse (maybe I'm doing it wrong). If anyone knows a simple way to smooth the acceleration values on such a low sample rate, please let me know, but for now we just assume acceleration is 0 in between updates.

    I'm not seeing any adverse effects from the calculations and frame times are still good, but it's hard to judge since my machine is pretty fast. Please let me know if you're seeing any slowdown attributable to this plugin.

    Oh yeah, lapDist is also being interpolated now and may occasionally exceed the max lap distance when close to the start finish. No big deal, but it's still worth a mention.

    Other than bug fixes, I'm not planning on making any more changes to this plugin and for now it should be considered good for use with other projects. Enjoy!
     
    • Like Like x 3
  9. Marcel Offermans

    Marcel Offermans New Member

    Joined:
    Feb 14, 2016
    Messages:
    8
    Likes Received:
    20
    We are getting more requests for information about some of the extensions that we've made and we will make those available when AMS is fully released, because right now we are still tweaking some of the elements in that structure. So be patient, it will happen, and probably those properties will indeed be there.
     
    • Like Like x 3
  10. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    I'm working on an update to the plugin DLL, just patching some potential security issues that have been nagging at me for a while and fixing some issues with my interpolation math.

    Any suggestions for changes are welcome, I'll be adding a version string soon to help with figuring out which version of the API the DLL is exporting. The new memory map is much smaller now, about 11kB compared to 39kB with the currently released version, so that should make it a lot better for any recording/playback systems that make use of it (such as pixeljetstream's trace analysis tools or mr_belowski's Crew Chief debug functions).
     
  11. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    I've just written an installer for the plugin DLL since we had some issues with people not being able to install it properly on their own before. This installer will automatically ask to run as admin and then search the registry for the install location of AMS, then copy the DLL to the Plugins folder.
     
    • Like Like x 1
    • Informative Informative x 1
  12. DaVeX

    DaVeX Active Member

    Joined:
    Mar 8, 2016
    Messages:
    594
    Likes Received:
    213
    Hi Gongo, we have to install it for crewchief or similar software?
     
  13. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    Yeah, the installer script will be included with pyDash and Crew Chief. You'll just run pluginInstaller.exe and it will automatically request admin rights, search the registry for the Automobilista install path, and then copy the updated DLL to the Plugins folder. It will automatically overwrite the file if you run it again. For people like you who are using both pyDash and Crew Chief, you really only need to run the plugin installer once, but it won't hurt anything if you run it multiple times. I tested it last night and it worked exactly like I wanted it to. I'll probably ask you to test it also before I release it publicly.
     
  14. DaVeX

    DaVeX Active Member

    Joined:
    Mar 8, 2016
    Messages:
    594
    Likes Received:
    213
    Ready for testing! :cool:
     
    • Winner Winner x 1
  15. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    I'll have a test build ready in the next day or two, still polishing up the auto-update functions (it goes out to my github to check for new versions and download the latest DLL). I'll message you with a link to the test build when it's ready. :)
     
  16. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    Ok, found some things with the plugin installer script, looks like Steam doesn't add back registry entries when you restore from backups or otherwise move files to different drives like many people appear to do around here. I guess I'm spoiled with 105 Mbps broadband and needed to be reminded that not everyone can quickly redownload their games, lol.

    Hopefully after this last round of testing, I should be ready to release the plugin installer and it should be much simpler for everyone to just double-click an exe and have it do everything for you. At least, that's the goal, anyway. ;)
     
    • Like Like x 1
    • Optimistic Optimistic x 1
  17. knackko

    knackko New Member

    Joined:
    Jul 25, 2016
    Messages:
    4
    Likes Received:
    0
    What a nice dev, I suppose like for telemetry+dash, rFactorSharedMemoryMaps can also be used with rFactor dedicated servers to get drivers time laps in order to do a liveview+hotlaps app (like pySRD9c). It is great as there is no need to take care about rf plugin part (I don't want to do C++dev, only python or php). Maybe just the RF_SHARED_MEMORY_NAME must be specified in external ini file to authorize several rFactorSharedMemoryMaps instances in case of several rFactor dedicated servers.
     
  18. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    Well, in order to access the memory map, you'll pretty much have to use a C/C++ library/API no matter which language you choose since they all seem to use C for that kind of low-level access anyway. For Python you'll be using the ctypes module and for Lua you'll be using ffi.

    I've never tested it on a dedicated server (let alone multiple dedicated servers running on the same machine). The intended use is for the client. Allowing the memory map to be renamed by a string in an INI file is probably asking for trouble, but I'll think about maybe appending the server port or something to see if we can get multiple instances running at once. No promises that I can get that working since it's a pretty extreme edge case and far out of the intended application of the plugin, but I'll look into it.
     
  19. gongo

    gongo Dan Allongo

    Joined:
    Mar 21, 2016
    Messages:
    370
    Likes Received:
    350
    @knackko the RF_SHARED_MEMORY_NAME will have the process id appended to it for each dedicated server instance so that you can run multiple instances and they don't clobber each other. I opted for this approach since it's likely that the multiple instances will be launched from the same install folder, so using an INI or config file would not work since they would all share the same value in the same file anyway. I needed to use something that I know is reliable and unique (during runtime, anyway) so the process id was the logical choice. It means you'll have to keep track of the process id for each dedicated server instance so you'll need to build the string dynamically (no hard-coded id since the appended suffix will change on each server restart).

    I've just tested and committed these changes to the codebase and it will be included in the next release of the DLL (whenever that happens).
     
    • Like Like x 1
    • Useful Useful x 1
  20. knackko

    knackko New Member

    Joined:
    Jul 25, 2016
    Messages:
    4
    Likes Received:
    0
    No config file for the plugin=>best choice !
    My devs to read shared memory file will be with python too, maybe with django or web2py (as django runs with python3, I think it will be my choice).
    The case of multiple instances will be launched from the same install folder is interesting because it is more tricky to work with but can result in a more efficient solution.
    So the python app can first scans rfactor.exe processes to get running servers and their processid and then will get shared memory file to get server infos. So no configuration will be required to add a rfactor server on the python app (liveview/livetiming) as all runnning servers will be shown in the admin panel. The process id changing at each restart of a rfactor instance, each instance must be identified in the python app with the lobby name, or maybe used ports. I think it is a common sense to get every running rfactor servers by default and afterwards, ignore one or more instances if needed with the help of the admin panel. I have now a good starting point for the python app with your dll design! :)
    I will be on holidays for the next 2 weeks, so I will test the new dll at my return !
     

Share This Page