Get kmh from the pilots on track

Discussion in 'Plugins' started by jcarrest, Aug 23, 2023.

  1. jcarrest

    jcarrest Registered

    Joined:
    Jan 11, 2012
    Messages:
    13
    Likes Received:
    0
    Hello, I am starting to know the internal plugin.

    I want to collect live track data to publish it on a website.
    I don't know if I understand how it works.
    With UpdateScoring I have seen that I can obtain the data of each pilot, but I can't find the way to obtain the speed of each one.
    I have tried UpdateTelemetry and only the info from my player.

    I have seen (vinfo.mLocalVel.x, vinfo.mLocalVel.y, vinfo.mLocalVel.z )) but I don't know if there is any formula from here.
    Could someone guide me?

    Thank you!
     
  2. Seven Smiles

    Seven Smiles Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,099
    Likes Received:
    1,152
    Crew Chief has

    Code:
            private static double getVehicleSpeed(ref rF2VehicleTelemetry vehicleTelemetry)
            {
                return Math.Sqrt((vehicleTelemetry.mLocalVel.x * vehicleTelemetry.mLocalVel.x)
                    + (vehicleTelemetry.mLocalVel.y * vehicleTelemetry.mLocalVel.y)
                    + (vehicleTelemetry.mLocalVel.z * vehicleTelemetry.mLocalVel.z));
            }
    
     
  3. jcarrest

    jcarrest Registered

    Joined:
    Jan 11, 2012
    Messages:
    13
    Likes Received:
    0
    thank you so much!
    I dind't know how to do it.
    Now it works perfectly!

    The next step would be to create a record of each lap of all the drivers. I think I can do it, but I don't know how to get the tire type and if you have used DRS or Push to Pass. Will the server return that data to me with the update telemetry?
     
  4. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    12,388
    Likes Received:
    6,602
    There's no info on DRS or P2P. Tyre compound index should be available.

    ** @jcarrest sorry, I'll correct myself and add a little more info. (just had a quick look at the example plugin again)

    Telemetry has the front and rear tire compound name, but you'll need to see how that goes for remote cars (any but yours if you are running the plugin; all cars if it's on the server). Flap activation (front and rear [DRS]) is also in there, and maybe some of the electric motor stuff could be useful - but I've never tested telemetry on remote vehicles, so how reliable (or available at all) it is you'd have to find out.

    The other option for things like laptimes and tyres is to use the results stream - it's nearly the same as what gets written out to session logs that tools like Log Analyzer use. That's in ScoringInfo.

    Make sure you read through and try to understand as much of the example plugin as possible (it has the speed calculation, for example). So both the example.cpp but also the InternalsPlugin.hpp, so you can get an understanding of what is (and isn't) available.
     
    Last edited: Aug 23, 2023
  5. svictor

    svictor Registered

    Joined:
    Jan 20, 2019
    Messages:
    936
    Likes Received:
    6,377
    P2P state can be determined by monitoring mElectricBoostMotorState value (# 0=unavailable 1=inactive, 2=propulsion, 3=regeneration). This value tells whether electric motor is activated or regenerating. However note that there are some P2P info cannot be read and missing from Plugin, such as the P2P cool down timer and when P2P is allowed to activate (different from mElectricBoostMotorState that only tells if e-motor is activated or not).
     
  6. jcarrest

    jcarrest Registered

    Joined:
    Jan 11, 2012
    Messages:
    13
    Likes Received:
    0
    Can you guide me?

    At the moment if I run it on the server it collects data through UpdateScoring, but nothing with UpdateTelemetry.
    Circuit=Circuit d'Azur
    Sesion=10 NumPilotos=1
    GamePhase=5 YellowFlagState=0 SectorFlags=(11,11,11)
    InRealtime=0 StartLight=0 NumRedLights=5
    PlayerName=Your Name PlrFileName=player
    DarkCloud=0.00 Raining=0.00 AmbientTemp=24.9 TrackTemp=47.7
    Wind=(0.0,0.0,0.0) MinPathWetness=0.00 MaxPathWetness=0.00
    Pilot 0: Jordan #17
    ID=0 Veh=Jordan #17
    Laps=2 Sector=0 FinishStatus=0
    LapDist=3221.0 PathLat=1.25 RelevantTrackEdge=5.58
    Best=(20.622, 60.086, 79.322)
    Last=(20.622, 60.086, 79.322)
    Current Sector 1 = 20.660, Current Sector 2 = 60.917
    Pitstops=0, Penaltis=0
    IsPlayer=0 InPits=0 LapStartET=316.814
    PositionRace=1 VehicleClass=F1-23
    TimeBehindNext=0.000 LapsBehindNext=0
    TimeBehindLeader=0.000 LapsBehindLeader=0
    Pos=(20.033,2.738,-89.217)
    Speed=234.9 KPH
     
  7. jcarrest

    jcarrest Registered

    Joined:
    Jan 11, 2012
    Messages:
    13
    Likes Received:
    0
    It wasn't myself running, but a BOT
     
  8. jcarrest

    jcarrest Registered

    Joined:
    Jan 11, 2012
    Messages:
    13
    Likes Received:
    0
    Hello, I'm still stuck on recovering the telemetry of all the vehicles.
    I am especially interested in, for example, mFuel, mRearFlapActivated, mRearFlapLegalStatus, mFrontTireCompoundIndex, mRearTireCompoundIndex, mWheel of each vehicle on the track from (TelemInfoV01).

    I would appreciate it if someone with compassion would make me see the light.

    for (long i = 0; i < info.mNumVehicles; ++i)
    {
    VehicleScoringInfoV01& vinfo = info.mVehicle;

    fprintf(fo, "<record>\n");
    fprintf(fo, "<position>%d</position>", vinfo.mPlace);
    fprintf(fo, "<iD>%d</iD>", vinfo.mID);
    fprintf(fo, "</record>\n");
    //here I want to receive data from the TelemInfoV01 structure in which mID matches
    //for example mFuel, mRearFlapActivated, mRearFlapLegalStatus, mFrontTireCompoundIndex, mRearTireCompoundIndex, mWheel

    }
    Thank you!
     

Share This Page