Shared Memory API

Discussion in 'Community Workshop' started by Mikael Hermansson, Jun 7, 2015.

  1. Mikael Hermansson

    Mikael Hermansson Well-Known Member

    Joined:
    May 3, 2015
    Ratings:
    +48 / 0 / -0
    There's been a couple of requests coming in for us to better document the API that we provide for the users of R3E. In case you weren't already aware, the game client currently creates a block of so called shared memory when starting up, which allows other applications on your computer to read certain data that we expose through this memory block.

    A few examples of the types of data exposed:
    • Data about the car, such as gear, RPM, speed, DRS, etc.
    • Data about the race, such as position, lap times, etc.
    • High-precision data about the player, such as physical position/rotation, G-forces on the driver, etc.
    This API has already been used by a couple of third-party applications and hardware manufacturers to allow R3E (and some older SimBin titles) to be used with stuff like this:
    As a first step, I've written a small sample application to allow you to clearly see the layout of the memory block and to help you get started. This particular sample is written in C, which seemed appropriate considering its wide interoperability with other languages. I could put up samples in other languages if anyone would be interested in that.

    You can find the layout and sample applications here on GitHub.

    Feel free to come with suggestions on stuff you'd like to see added to the API, either here on the forum or on the GitHub issue tracker

    EDIT (21/6/15): Added a C# sample to the GitHub repo.
    EDIT (12/7/15): Added a bunch of new entries to shared memory (with some caveats).
    EDIT (1/3/17)
    - New minor version is 3.
    - Added new entries for extended flags.
    - Changed how tire wear is reported so it now matches the % shown on the new data displays.
     
    • Like x 7
    • Informative x 4
    • Love it! x 3
    • Wonderful x 3
    • Winner x 2
    Last edited by a moderator: Mar 9, 2017
  2. pixeljetstream

    pixeljetstream Well-Known Member Beta tester

    Joined:
    Jan 29, 2015
    Ratings:
    +416 / 0 / -0
    great!

    first thing I would add is a version header at the very top, making it easier for 3rd party apps to deal with future changes (some magic value to ensure it's r3e + version number).

    Given there is no MoTec support in r3e (and one has to license their stuff...) I wonder if you can add the full set of telemetry related data, so one could create something similar (brake %, gas %, steering angles, tire, dampers...). Some people are building nice telemetry tools for another racing game and maybe they could be convinced to make their apps not linked to just one game, but generic as long as the needed data can be provided somehow, or if that fails, community could build its own tool for r3e.
     
    • Like Like x 3
    • Useful Useful x 1
  3. Mikael Hermansson

    Mikael Hermansson Well-Known Member

    Joined:
    May 3, 2015
    Ratings:
    +48 / 0 / -0
    As much as I'd like to add a version header of some sort, we're sort of constrained by what's already out there. This API has been out in the wild for a good long while now, and people have already integrated their applications with it. If we were to add new members to the top we'd offset every subsequent member and mess up their integration. This is obviously the reason why you have a version header in the first place, but it is what it is.

    We could maybe potentially re-use some of the first 24 bytes that's been used for "userInput" in older SimBin titles, but it was only the other day that I noticed that those aren't being used in R3E, so I'm not sure what current implementers are expecting from those bytes.

    Our policy going forward will be to try very hard to not disturb the existing layout and only add members at the end of the memory block.

    Regarding the missing telemetry data, I'll look into if we can have it for the next patch. As long as we have easy access to the data, it should be a breeze to get it in the shared memory.
     
  4. taxfree

    taxfree Well-Known Member

    Joined:
    Feb 24, 2015
    Ratings:
    +51 / 0 / -0
    Is there any server side API/SDK for C/C++?
     
  5. Mikael Hermansson

    Mikael Hermansson Well-Known Member

    Joined:
    May 3, 2015
    Ratings:
    +48 / 0 / -0
    There's no memory block or anything like what we have with the client, no. There is an HTTP API that the frontend for Dedicated Server uses, but I'm not sure if there's any solid documentation for that just yet.
     
  6. taxfree

    taxfree Well-Known Member

    Joined:
    Feb 24, 2015
    Ratings:
    +51 / 0 / -0
    Yes, I've read about the API for web developers.
    But why not the shared memory?
     
  7. Mikael Hermansson

    Mikael Hermansson Well-Known Member

    Joined:
    May 3, 2015
    Ratings:
    +48 / 0 / -0
    Were you hoping to get some kind of data out of the server, or are you looking for some way to control it? Depending on what you want we might be able to make some changes.
     
  8. taxfree

    taxfree Well-Known Member

    Joined:
    Feb 24, 2015
    Ratings:
    +51 / 0 / -0
    Great!
    Yes, getting live data from the server would be very useful.
    Even better when I can take some control.

    e.g.) Server tool for Admin
    Online status monitoring.
    Automated message broadcast.
    Driver statistics management.
    Leaderboard.
    :
     
  9. sdecorme

    sdecorme New Member

    Joined:
    Jun 2, 2015
    Ratings:
    +0 / 0 / -0
    Do you have the project in c# ?
    I have to put it in my game controller.
    if you don't,I 'll make a project from your C sample
    What is the data update refresh frequency ?
    Thanks for the informations.
     
    • Useful Useful x 1
  10. Mikael Hermansson

    Mikael Hermansson Well-Known Member

    Joined:
    May 3, 2015
    Ratings:
    +48 / 0 / -0
    I don't have one right now, no, but I can set one up later this week if you'd like.
    It's once every update tick (not simulation tick), which depends on your CPU, but it will be up to 512 hz if I'm not mistaken. I'll see if I can make a note of it on GitHub somewhere.

    EDIT: Seems I was mistaken after all. The values will be updated at 512 hz, but it won't get any new values until relevant subsystems are updated obviously, which run at 400 hz. Either way it should hopefully be fast enough for most. :)
     
    • Informative Informative x 1
    Last edited: Jun 8, 2015
  11. sdecorme

    sdecorme New Member

    Joined:
    Jun 2, 2015
    Ratings:
    +0 / 0 / -0
    Ok thanks you ,
    I will wait, I'm not at the office , I will be back next week.
    All the data are updated at 400hz ? It is amazing I will send this post to the other game builder;)
     
  12. Tom Burning

    Tom Burning New Member

    Joined:
    Feb 2, 2015
    Ratings:
    +3 / 0 / -0
    Cool,stuff, so now I can adapt my self-made dashboard to work with R3E as well.

    If we may add some wishes, here I have 3.
    FLAGS
    BREAK-PEDAL-POSITION
    BREAK-BIAS
     
    • Agree Agree x 1
    • Winner Winner x 1
    • Useful Useful x 1
  13. Ernie

    Ernie Well-Known Member

    Joined:
    Jan 29, 2015
    Ratings:
    +304 / 0 / -0
    I'm not an API developer, but couldn't resist a quick look at the source files. :rolleyes:

    What i think would also be useful for API output:
    • Pedal positions (clutch, brake and throttle)
    • Driving assists/aids (to see what is currently active or available)
    • FFB output (for creating something like a FFB meter)
    • Infos about incidents/contacts with other players and/or environment
    Sorry if some of this data is already available in API and i had possibly overseen it.:confused:
     
    • Useful Useful x 1
  14. Mikael Hermansson

    Mikael Hermansson Well-Known Member

    Joined:
    May 3, 2015
    Ratings:
    +48 / 0 / -0
    Thanks for all the great suggestions, guys.

    The pedal stuff shouldn't be any problem getting in. I can't imagine the driving aid stuff would be either. The other ones I'll have to look into. The incident one might be tricky, since the layout of the block is very static, so a dynamic list of any kind will be difficult to manage, at least in a portable way.
     
    • Informative Informative x 1
  15. ViperNo23

    ViperNo23 Member

    Joined:
    Feb 1, 2015
    Ratings:
    +17 / 0 / -0
    I think it would also be great to get some info regarding the pits.
    eg. info if you are in the pitlane or not or have the pitlimiter on or not (for the flashing led's when in the pitlane or the pitlimiter is activated)
    some kind of delta laptime would also be interesting, but that one might be a little more tricky since there currently is no info about it.
     
    • Like Like x 1
  16. le_poilu

    le_poilu Well-Known Member

    Joined:
    Jan 30, 2015
    Ratings:
    +278 / 0 / -0
    I'de love to have more timing info.
    I use dashmeter pro, the GCS/rf or AC version gave me split on last and best time witch is very handy when it come to improve your time and keep your pace. Would be great to have the same in R3E.
    On the Rf/GSC side we even have the delta between other driver with relative position

    The more data we can have through API, the less we need to use HUD, the better the immersion is !

    Cars data:
    Tire temp with inner/center/outer
    Tire pressure
    Brakes Temp
    Damages (engine, gearbox, body, drivetrain)
    Fuel : capacity, consumption, ...
    Pit limiter
    Pit speed limit

    RaceData:
    Flags (green, yellow, blue, black)
    Race length - Remaining
    Position with deltas

    Timings:
    Split time by sector
    Last lap
    Best lap
    Delta with last
    Delta with best
    Best session time (all drivers) with deltas

    Driverdatas:
    Pedales info Brake/accel./clutch

    and more and more :D
     
    • Agree Agree x 2
    • Like Like x 1
    Last edited: Jun 9, 2015
  17. Exxon

    Exxon Member

    Joined:
    Jan 30, 2015
    Ratings:
    +11 / 0 / -0
    Hello Mikale I have a question it is in the future of S3 be a possibility that all the data such as tires and brake temperature and all proposals that have already been made here can be programmed by you or I have to a program where load differently in the options ?
    Personally, I would have wished that such programs in the game would come exclusively from S3 and not from secondary suppliers.
    Many Thanks.
     
  18. Exxon

    Exxon Member

    Joined:
    Jan 30, 2015
    Ratings:
    +11 / 0 / -0
    I personally found the XD program for Race07 and GTR2 of Yako very very good. Is it possible to get such a program of what you will be automatically installed with the game and you could activate it in the options.
    Not everyone has a second monitor or wants to so a program like Motec.
    So you could see the most important in the race which is sufficient.
     
    • Agree Agree x 1
  19. Mikael Hermansson

    Mikael Hermansson Well-Known Member

    Joined:
    May 3, 2015
    Ratings:
    +48 / 0 / -0
    The data we're exposing here is specifically for third-party applications. Any data we expose through this API is already available to our own developers, but we might not show it to the end-users in the game for various reasons. If you see some data you'd very much like to see in the game then feel free to make a feature request in our General Discussion section of the forums and we'll see what we can do.
    I haven't personally checked out XD, but if that's something that improved your gaming experience with those titles then that is exactly the sort of thing we want to encourage with this stuff. We don't have any plans to bundle such applications with the game though. A more centralized place to find them would be nice though.
     
  20. Exxon

    Exxon Member

    Joined:
    Jan 30, 2015
    Ratings:
    +11 / 0 / -0
    Hello Mikael thanks for the quick reply.
    Here is a link from the program what I meant.
    Such a thing would be programmed from S3 me personally totally rich and I think many others as well.
    http://www.vitumo.de/
    :)
     
    • Like Like x 4