• Welcome to Kart Racing Pro Official Forum. Please login or sign up.
 
March 19, 2024, 05:30:33 AM

News:

Please read the FORUM RULES


Live Timing

Started by PiBoSo, October 08, 2012, 10:27:43 PM

Previous topic - Next topic

PiBoSo

October 08, 2012, 10:27:43 PM Last Edit: March 29, 2022, 11:24:25 AM by PiBoSo
It is possible to connect to a dedicated server or challenge server to receive live race data.
The feature is off by default and must be enabled:
http://forum.kartracing-pro.com/index.php?topic=8.0
http://forum.kartracing-pro.com/index.php?topic=3609.0
Only 1 client can connect to the server.

Communication is made with UDP sockets and strings terminated with "\n".

Send "CONNECT" followed by the connection password ( empty string if no password ).
Reply:
OK -> connected
FULL -> another client is already connected
WRONGPASSWORD -> wrong password

Send "START", followed by two parameter strings to start receiving data.
First parameter: either "0" or "1". If set to "1", the track centerline and the track position of the karts are sent, too.
Second parameters: either "0", "1" or "2". If set to "1", the contacts between karts are sent. IF set to "2", contacts between karts and walls are sent, too.

Data format is "MSG" followed by the message ID and then a stream of strings.
Send "ACK" followed by the message ID after each MSG.

Send "KEEPALIVE" every 15 seconds to keep the connection active.
The server sends "ALIVE" to report that the connection is active.

Send "DISCONNECT" to correctly close the connection.

Example source code can be downloaded at this link: http://www.kartracing-pro.com/downloads/livetiming.c


Messages data format

EVENT
Type
- TESTINGDAY
- RACE
Name
Track
Track Length ( meters )
Allowed Categories and Karts
Empty string

Challenge server only:
EVENT
Type
- CHALLENGE
Name
Track
Track Length ( meters )
Allowed Categories and Karts
Challenge Type
- PRACTICE
- RACE
Challenge Length ( minutes if practice, laps if race )
Challenge Max Tries
Empty string

ENTRY
Race Number
Name
Kart Name
Kart Short Name
Categories
GUID
Extra
Empty string

ENTRYREMOVE
Race Number
Empty string

Testing Day:
SESSION
Session
- WAITING
- TESTINGDAY
State
Length
Empty string

Race:
SESSION
Session
- WAITING
- PRACTICE
- QUALIFY
- WARMUP
- QUALIFYHEAT
- SECONDCHANCEHEAT
- PREFINAL
- FINAL
State
if session = practice ( PRACTICE, QUALIFY, WARMUP )
- INPROGRESS
- COMPLETE
else if session = race ( QUALIFYHEAT, SECONDCHANCEHEAT, PREFINAL, FINAL )
- WARMUPLAP
- PRESTART
- ROLLINGSTART
- STARTSEQUENCE
- INPROGRESS
- RACEOVER
- COMPLETE
endif
Length ( minutes if practice, laps if race )
Empty string

SESSIONSTATUS
Session
- WAITING
- PRACTICE
- QUALIFY
- WARMUP
- QUALIFYHEAT
- SECONDCHANCEHEAT
- PREFINAL
- FINAL
State
if session = practice ( PRACTICE, QUALIFY, WARMUP )
- INPROGRESS
- COMPLETE
else if session = race ( QUALIFYHEAT, SECONDCHANCEHEAT, PREFINAL, FINAL )
- WARMUPLAP
- PRESTART
- ROLLINGSTART
- STARTSEQUENCE
- INPROGRESS
- RACEOVER
- COMPLETE
endif
Empty string

Always sent after SESSION:
WEATHER
Conditions
- CLEAR
- CLOUDY
- RAINY
Air Temperature
Track Temperature
Empty string

SESSIONENTRY
Race Number
Empty string

DRIVERSTATUS
Race Number
State
- DNS
- RET
- DSQ
if state = DSQ
Reason
- JUMPSTART
- TOOMANYOFFENCES
- ROLLINGSTARTSPEEDING
- ROLLINGSTARTTOOSLOW
- ROLLINGSTARTCORRIDOR
- ROLLINGSTARTOVERTAKE
- DIRECTOR
endif
Empty string

BESTLAP
Race Number
Session Time ( milliseconds )
Lap Time ( milliseconds )
Lap Number
Split 1 ( milliseconds )
Split 2 ( milliseconds )
Speed Trap ( meters/s )
Empty string

LASTLAP
Race Number
Session Time ( milliseconds )
Lap Time ( milliseconds )
Lap Number
Split 1 ( milliseconds )
Split 2 ( milliseconds )
Speed Trap ( meters/s )
Empty string

PENALTY
Race Number
Penalty Number
Type
- TIME
- POS
if type = TIME
Penalty Time ( seconds )
else
Counter
endelse
Offence
- JUMPSTART
- CUTTING
- ROLLINGSTARTSPEEDING
- ROLLINGSTARTTOOSLOW
- ROLLINGSTARTCORRIDOR
- ROLLINGSTARTOVERTAKING
Empty string

LAP
Race Number
Lap Invalid
Session Time ( milliseconds )
Lap Time ( milliseconds )
Split 1 ( milliseconds )
Split 2 ( milliseconds )
Speed Trap ( meters/s )
Empty string

SPLIT
Race Number
Split Number
Split Time ( milliseconds )
Empty string

SPEED
Race Number
Speed Trap ( meters/s )
Empty string

CLASSIFICATION
Session
Status
Session Timer ( milliseconds )
Session Length ( minutes )
Session Lap
Number of Laps
for each entry:
Race Number
if the session is practice ( practice, qualify, warmup )
Best Lap ( milliseconds )
if best lap not zero
Lap Number
Total Laps
Gap ( milliseconds, -- if zero )
Speed ( meters/s )
endif
else
Race Time ( milliseconds ) or Status
- DNS
- DSQ
if Race Time not zero
Lap Number
Gap ( milliseconds or L if lapped )
endif
endelse
Kart Status
- TRK: on track
- PIT: in the pits
endfor
Empty string after the last entry

Challenge server only:
CHALLENGEDATA
Name
Kart Name
Kart Short Name
GUID
Extra
Try Number
if challenge practice:
Best Lap ( milliseconds )
Lap Number
Total Laps
endif
Empty string

TRACKDATA
Start / Finish Longitudinal Position
Split 1 Longitudinal Position
Split 2 Longitudinal Position
Speed Trap Longitudinal Position
Number of Segments
Empty string

TRACKSEGMENT
Segment Number
Type ( 0 = straight, 1 = curve )
Length ( meters )
Radius ( meters )
Angle ( degrees )
Start Position X ( meters )
Start Position z ( meters )
Height ( meters )
Empty string

TRACKPOSITION
for each entry on track:
Race Number
Position X ( meters )
Position Y ( meters )
Position Z ( meters )
endfor
Empty string after the last entry

CONTACT
Time ( milliseconds )
Race Number 1 ( -1 if wall )
Race Number 2 ( -1 if wall )
Relative Velocity ( meters/s )
Empty string

END
Empty string

NOP

October 09, 2012, 02:04:35 PM #1 Last Edit: October 09, 2012, 02:31:47 PM by NOP
I have some problems.
After connecting to server i get
"MSG 0 SESSION WAITING" (newlines removed)
i send ack and server goes silent (not counting "ALIVE" messages)
after connecting to server i'm getting
"MSG 1 SESSION QUALIFY INPROGRESS WEATHER CLEAR 0.0 0.0 ENTRY 4 NOP. B F100 B F100"
each time after that i send (i think i didn't cock this up) "ACK\n" and "1\n" (ID + '\n').
But server keeps sending same "MSG 1..." even if another client joins session (and this message is constantly repeated).
\
Nevermind my bad.

PiBoSo

Quote from: NOP on October 09, 2012, 02:04:35 PM
I have some problems.
After connecting to server i get
"MSG 0 SESSION WAITING" (newlines removed)
i send ack and server goes silent (not counting "ALIVE" messages)
after connecting to server i'm getting
"MSG 1 SESSION QUALIFY INPROGRESS WEATHER CLEAR 0.0 0.0 ENTRY 4 NOP. B F100 B F100"
each time after that i send (i think i didn't cock this up) "ACK\n" and "1\n" (ID + '\n').
But server keeps sending same "MSG 1..." even if another client joins session (and this message is constantly repeated).
\
Nevermind my bad.

Good to know you solved the problem.

NOP

October 09, 2012, 03:26:55 PM #3 Last Edit: October 09, 2012, 03:36:25 PM by NOP
Quote from: PiBoSo on October 09, 2012, 02:35:21 PM
...
Good to know you solved the problem.
Now i feel compelled to explain.
What i think i did was send one message "ACK\n" and then next message ID + '\n'. Proper way was to send one message "ACK\n" + ID + '\n'. And it seems to work.

For people wondering what is Live Timing, it's some very basic data about karts times in splits and on start meta line. There is also some info about track and session.
Maybe it will find some use in leagues to present players more statistics (like consistency of drivers), or give server admins a bit more knowledge about what is going on in server. Or maybe i just don't get it  :P.

PiBoSo

October 09, 2012, 04:03:42 PM #4 Last Edit: October 09, 2012, 04:13:43 PM by PiBoSo
Quote from: NOP on October 09, 2012, 03:26:55 PM
For people wondering what is Live Timing, it's some very basic data about karts times in splits and on start meta line. There is also some info about track and session.
Maybe it will find some use in leagues to present players more statistics (like consistency of drivers), or give server admins a bit more knowledge about what is going on in server. Or maybe i just don't get it  :P.

The idea is to give the possibility to stream race data to a web page or to an application ( like many real-life live timing services ).
It was kept simple to be as flexible as possible.

dibu

NOP will you code something for public use?  Maybe it's also worth to have a look at GameQ ( http://gameq.sourceforge.net/ ). Possibly a profile for KRP can be added.

This morning I also played around with the live timing but very basicly. I mainly used Netcat (nc.exe) for testing.

NOP

Well i was doing app but i don't know how much sense is in doing something that will be visible only to one person. I guess i can slap some GUI and add data logging but i don't see big point to be honest.

dibu

You are right, but you know if there is a new toy we have to play with it until it gets boring  ;)
I just thought maybe you have already a quick and dirty tool for testing. Everything is better than nc.exe and a hexeditor  ;D


Aritz

It will be interesting to have some kind of races/championships administration plugin for websites:

http://www.liveforspeed.es/modules.php?nombre_carrera=Vuelta al cole 6.0&op=modload&name=liga&file=consulta_carrera

NOP

I'am completely green if it comes to writing websites... but it would be neat thing too learn.
For now dibu if you want i will wrap my program with some user interface to make it a bit easier to use and maybe you will find it useful.

dibu

Same for me with the websites  ::)
If it's not too much work, I would be happy to get your program  :)

PiBoSo

Quote from: Aritz on October 09, 2012, 07:55:13 PM
It will be interesting to have some kind of races/championships administration plugin for websites:

http://www.liveforspeed.es/modules.php?nombre_carrera=Vuelta al cole 6.0&op=modload&name=liga&file=consulta_carrera

What technology is used for that website?

NOP

Ok simple Live Timing logger
http://www.sendspace.pl/file/6b436eaacde80195c061e9d

Before starting server add configuration
[live]
enable = 1; 1 to enable live timing
port = 10660; the UDP port
password = admin

Start server, start logger if you didnt change anything click "connect" button.
Connection state should change to "OK". If it says "FULL" close program and try again after more than 15 seconds.

Messages from server will appear "Server data" label.
All messages are logged into text file. Slight difference is that rather than saving newlines '\n' I'm changing them to '|' sign. It keeps log file a bit more redable and still allows for easy parsing (file is open for writing and immediately closed).

If i didn't cocked something there will be also displayed times of sectors.

Aritz


dibu

Thank you NOP  :)
I just did a quick test and it works. In the log all MSG are properly ACKed. The splits and the laptime shows up. I'll do some more testing in the evening.