Other F1 2018 (PS/4) - UDP-Capture - Share my Code and request for help

DonManfred

Expert
Licensed User
Longtime User
This is a Example of Capturing UDP-Packets which comes from a PS/4 game while doing a race.
It is using RandomAccessfile to parse the Different UDP-Packets.

You can find the UDP-Specifications here.
Each of the described UDP-Packets are parsed by the Class into different CustomTypes and holding two Global Maps.

B4X:
    Public glData As Map
    Public RaceDriverMap As Map

glData: This Map contains a Live capture of the active Session.
There is a Session key which holds Information about the Session itself.

And for each driver in the race there is a Map with all additional infos about this Driver/Car.
All the Carsetup-Infos, Car-Status, Car Telemetry Data, Raceposition, best lap time and so on.

RaceDriverMap: Holds a Map for each RaceDriver(customtype). This map is used to get all drivers, sort them by Position (in the race) using list.sorttype and then update the Table in the other window.

tv_053.png


It seems that is does work fine with local games captured... It is me who is playing the game on my Playstation.

But i fear it does not work correctly with a Online Race. Basically one should be able to recognize a driver with the given Grid-Position. It should not change while in session.

---- Setup PS/4 - F1 2018 Settings ------
- In the Game you need to go to the game settings. Here you find a Telemetry setting

telemetryoptions.jpeg


Use the IP from your PC running the B4J Project.
- Port 20777
- UDP-Format should be set to 2018


I´m not sure if everything is working as expected ;-)

Dependencies:
- It is only interesting if you own the Codemasters Game F1 2018 for your Playstation.
- It may be possible to use it in the PC-Version of the Game too.
- You must have configured the game to send the UDP Telemetry Data to your PC.

What i did not understand as of now (need help with it).
- I get in the Data all drivers WorldPositionX/Y/Z
The values ranged from -xxx.xxxx to +xxx.xxxx
and i´m wondering if i could "paint" the position on a Canvas but i´m not able to convert the positions into a canvas position to draw something like a track.
Unfortunately i do not have any Trackgraphics which i could use. Also if i had them; i still needed to underastand how to convert the WorldPositions to a Bitmap-Pixelposition.
For ex:
B4X:
 SELECT max( `live_worldPositionX` ) AS maxX, max( `live_worldPositionY` ) AS maxY, max( `live_worldPositionZ` ) AS maxZ, min( `live_worldPositionX` ) AS minX, min( `live_worldPositionY` ) AS minY, min( `live_worldPositionZ` ) AS minZ
FROM `f1_live_data`
WHERE `live_sessionID` =458
results in

maxX maxY maxZ minX minY minZ
1022.2056 3.7142 1047.0760 -819.6987 -143.0191 -603.8157

Any help rthis regarding is higly appreciated. I´m doing this project for a friend.

Feel free to play with the tool. If you find any problem and know a Fix for it. Post the fix so anyone can apply them.

Have fun!
 

Attachments

  • F12018udpEx.zip
    47.2 KB · Views: 477
Last edited:

Cableguy

Expert
Licensed User
Longtime User
This looks very cool...
I understand this is a work in progress, and progressing very well I must say...
If I may suggest, since the track layout is known, and the stating line positions for each track are known too, why not just draw the cars dots over the "real" track? that would give a big "graphic WOW" to it
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
since the track layout is known
i know the points i get (or i can calculate) from the UDP-Data. The Orientation of the "Real world Tracks" may be different.
stating line positions for each track are known too
starting from that i do not know which Lat/Lon i need to use. And, much more important. I just do not know how to "Transform" the Game-World-Coordinates which i get to working Lat/Lon Values which i could use to update Markers on a Google Map.

that would give a big "graphic WOW" to it
Sure it would. And if i knew how to Calculate Real World Coordinates from the data i would pleased to update the graphic and use Google Maps instead.

I just do not know how :)

I started the thread here to get help converting the WorldPositions to Screencoordinates which i can use on a Canvas. This is working fine now. For now only one Track is tested as of now. 5 Tracks i do have the Backgroundgraphic for, the rest will follow in the next days. Work in progress

Can you help on the Issue to Convert the Values to Lat/lon?
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Sorry, I never even worked with GPS before...
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
A suggestion to get real world to game world coordinates ( a bit of a PITA but only need to do once per track)

Drive a single car around the game track, stopping at mid-corner for the entire track.
This will give you the game cords of the corner.
Google maps will supply the lat/lon if you click on the map in the equivalent place.

Simply map the game coords to the google lat/lon, this should give a scale factor for x and z. (the map ingame is orientated just as the real track is)
 
Upvote 0
Top