1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Lesson How to add Telemetry output into a game. (Simple Example)

Discussion in 'Tutorials and Tips by the Developer' started by yobuddy, Oct 26, 2017.

  1. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,160
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,139Coins
    Ratings:
    +5,036 / 16 / -0
    I have been asked a few times on how to add telemetry output into a game.
    So today I thought I would show one way of achieving such a goal.

    Remember that SimTools is designed so it can capture telemetry output from a game no matter how it is outputting telemetry data. In other words, SimTools conforms to the games output method, rather than the game having to do anything special for SimTools.

    I believe the easiest way to output telemetry is thru UDP, so that is the way I’m going to show here. Other ways of outputting telemetry is with the use of Memory Mapped files and even a custom API’s.

    Ok let’s get started!
    First, let’s make the game a settings file to hold the Telemetry settings for the game.
    I’m suggesting a ‘Telemetry.cfg’ file that holds the motion configuration for the game.

    You may already have a configuration file for the game that you want to put these settings in, this is just an example. (This also gives SimTools a file to patch for motion, and allows the telemetry outputting to be on or off as needed.)

    The Telemetry.cfg file holds these 4 settings:
    - Enable_Telemitry = False
    - IpAddress = 127.0.0.1
    - Port = 4123
    - MS_OutputRate = 10

    I wrote the following example code in VB.net, as its dead simple to read and see what I’m doing.
    Basically thou, I’m creating a looping background thread that builds and sends the needed output with UDP.
    Once you have ‘something like’ this code in the game, all you have to do is:
    Call ‘Start_Telemetry_Output()’ when the game starts up.
    And ‘Stop_Telemety_Output()’ when the game shuts down.

    Ok, now some code:
    Private Telemetry_Sender As New UdpClient
    Private Telemetry_Loop_ms As Integer
    Private
    Telemetry_Running As Boolean = False
    Private
    Telemetry_Thread As Threading.Thread

    'Starts up the Telemetry Sender.
    Private Sub Start_Telemetry_Output()
    'only startup if not already started.
    If Telemetry_Running = False Then
    'read from Telemtry cfg file.
    Dim Telemitry_Enabled AsString = "Get Enabled_Telemetry value from the Telemetry.cfg file"
    Dim IpAddress AsString = "Get IpAddress value from the Telemetry.cfg file"
    Dim Port AsString = "Get Port value from the Telemetry.cfg file"
    Dim MS_OutputRate AsString = "Get MS_OutputRate value from the Telemetry.cfg file"

    If CBool(Telemitry_Enabled) = True Then
    Try
    'startup a new client.
    Telemetry_Sender = New UdpClient
    Telemetry_Sender.Connect(IpAddress, CInt(Port))

    'set loop speed & start sending data.
    Telemetry_Loop_ms = CInt(MS_OutputRate)
    Telemetry_Running = True
    Telemetry_Thread = New Threading.Thread(AddressOf Telemetry_Loop)
    Telemetry_Thread.IsBackground = True
    Telemetry_Thread.Start()
    Catch ex As Exception
    'Could not create the UDP sender, no need to do anything.
    End Try
    End If
    End If
    End Sub

    'Send Telemetry
    Public Sub SendTelemetry()
    Try
    'Collect the data.
    Dim Roll As String = ""
    Dim Pitch As String = ""
    Dim Yaw As String = ""
    Dim RollSpeed As String = ""
    Dim PitchSpeed As String = ""
    Dim YawSpeed As String = ""
    Dim Vertical As String = ""
    Dim Lateral As String = ""
    Dim Longitudinal As String = ""
    'add anything else you want to add, its easy now!
    'Dim Rpm As String = ""
    'Dim Speed As String = ""


    'check the status to see if the game is being played (In Game, In Menus, Paused).
    Dim Game_Is_Playing As Boolean = 'Get if the game is being played)

    'game is actually being played check.
    If Game_Is_Playing = True Then

    'If game is actually being played (not in menus or paused).
    Roll = "Get value from your game" 'in degrees - (-180 to 180)
    Pitch = "Get value from your game" 'in degrees - (-180 to 180)
    Yaw = "Get value from your game" 'in degrees - (-180 to 180)
    RollSpeed = "Get value from your game" 'in (rad/sec)
    PitchSpeed = "Get value from your game" 'in (rad/sec)
    YawSpeed = "Get value from your game" 'in (rad/sec)
    Vertical = "Get value from your game" 'in g's acceleration
    Lateral = "Get value from your game" 'in g's acceleration
    Longitudinal = "Get value from your game" 'in g's acceleration
    Else
    'If the game is paused or in the menus. (not actually being played)
    Roll = "0" 'in degrees - (-180 to 180)
    Pitch = "0" 'in degrees - (-180 to 180)
    Yaw = "0" 'in degrees - (-180 to 180)
    RollSpeed = "0" 'in (rad/sec)
    PitchSpeed = "0" 'in (rad/sec)
    YawSpeed = "0" 'in (rad/sec)
    Vertical = "0" 'in g's acceleration
    Lateral = "0" 'in g's acceleration
    Longitudinal = "0" 'in g's acceleration
    End If

    'Build the output string. (The 'S~' and the '~E' is so the user can see if they have a complete string of inputs)
    Dim WhatToSend As String = "S~Roll:" & Roll & "Pitch:" & Pitch & ":Yaw:" & Yaw & "RollSpeed:" & RollSpeed & "PitchSpeed:" & PitchSpeed & ":YawSpeed:" & YawSpeed & "Vertical:" & Vertical & ":Lateral:" & Lateral & ":Longitudinal:" & Longitudinal & "~E"

    'Send the string
    Dim bytCommand As Byte() = NewByte() {}
    bytCommand = Encoding.UFT8.GetBytes(WhatToSend)
    Telemetry_Sender.Send(bytCommand, bytCommand.Length)​
    Catch ex As Exception
    'something went wrong, turn off telemetry output.
    Stop_Telemity_Output()​
    End Try
    End Sub

    'Stop Telemetry Output
    Public Sub Stop_Telemetry_Output()
    'only shutdown if already started.
    If Telemetry_Running = True Then
    'turn output off.
    Telemetry_Running = False
    'let it finish what its doing.
    Threading.Thread.Sleep(100)
    'Close Client.
    Telemetry_Sender.Close()​
    End If
    End Sub

    'Send Telemetry Loop
    Private Sub Telemetry_Loop()
    'Send Telemetry.
    SendTelemetry()
    'pause till next packet is needed.
    Threading.Thread.Sleep(Telemetry_Loop_ms)
    'loop again if needed.
    If Telemetry_Running = True Then
    Telemetry_Thread = New Threading.Thread(AddressOf Telemetry_Loop)
    Telemetry_Thread.IsBackground = True
    Telemetry_Thread.Start()​
    End If
    End Sub

    That’s all there is to it!
    I hope this example is helpful.
    Let me know if I can be of any help!
    Take Care,
    yobuddy

    Source code of the example above:

    Attached Files:

    • Like Like x 5
    • Winner Winner x 4
    • Informative Informative x 2
    Last edited: Aug 29, 2019
  2. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,520
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    144,950Coins
    Ratings:
    +10,770 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    • Like Like x 2
  3. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,520
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    144,950Coins
    Ratings:
    +10,770 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  4. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,160
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,139Coins
    Ratings:
    +5,036 / 16 / -0
    • Like Like x 1
    • Agree Agree x 1
  5. Gadget999

    Gadget999 Well-Known Member

    Joined:
    Dec 27, 2015
    Messages:
    1,897
    Location:
    London
    Balance:
    11,610Coins
    Ratings:
    +458 / 9 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    awesome !

    can you recommend a tool to read the telemetry - i guess excel would do the job
  6. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,160
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,139Coins
    Ratings:
    +5,036 / 16 / -0
    Anything that can catch and make use of UDP packets really.
    Take care,
    yobuddy
  7. ChevCheliosSun

    ChevCheliosSun New Member

    Joined:
    Mar 7, 2020
    Messages:
    5
    Balance:
    62Coins
    Ratings:
    +1 / 0 / -0
    Hi!
    I have this code in UE4 plugin (C#). How to change it to be the correct format? (The "S~" with tell us the start of a string and the ~E will let us know there is a end. The ":" will be used for a delimiter.)

    Code:
    TArray<FString> telemetry;
        telemetry.Add(FString::SanitizeFloat(Roll));
        telemetry.Add(FString::SanitizeFloat(Pitch));
        telemetry.Add(FString::SanitizeFloat(Yaw));
        telemetry.Add(FString::SanitizeFloat(Heave));
        telemetry.Add(FString::SanitizeFloat(Sway));
        telemetry.Add(FString::SanitizeFloat(Surge));
        telemetry.Add(FString::SanitizeFloat(Extra1));
        telemetry.Add(FString::SanitizeFloat(Extra2));
        telemetry.Add(FString::SanitizeFloat(Extra3));
        FString ToSend = FString::Join(telemetry,_T(","));
        TCHAR *data = ToSend.GetCharArray().GetData();
        SenderSocket->SendTo((uint8*)TCHAR_TO_UTF8(data), FCString::Strlen(data), BytesSent, *RemoteAddr);
  8. ChevCheliosSun

    ChevCheliosSun New Member

    Joined:
    Mar 7, 2020
    Messages:
    5
    Balance:
    62Coins
    Ratings:
    +1 / 0 / -0
    Sorry it was easier than I thought :)


    TArray<FString> telemetry;
    telemetry.Add(FString::FString("S~"));
    telemetry.Add(FString::SanitizeFloat(Roll));
    telemetry.Add(FString::SanitizeFloat(Pitch));
    telemetry.Add(FString::SanitizeFloat(Yaw));
    telemetry.Add(FString::SanitizeFloat(Heave));
    telemetry.Add(FString::SanitizeFloat(Sway));
    telemetry.Add(FString::SanitizeFloat(Surge));
    telemetry.Add(FString::SanitizeFloat(Extra1));
    telemetry.Add(FString::SanitizeFloat(Extra2));
    telemetry.Add(FString::SanitizeFloat(Extra3));
    telemetry.Add(FString::FString("~E"));
    FString ToSend = FString::Join(telemetry, _T(":"));
    TCHAR *data = ToSend.GetCharArray().GetData();
    SenderSocket->SendTo((uint8*)TCHAR_TO_UTF8(data), FCString::Strlen(data), BytesSent, *RemoteAddr);
    • Like Like x 1
  9. balajee8848

    balajee8848 New Member

    Joined:
    Mar 12, 2021
    Messages:
    2
    Balance:
    - 14Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    2DOF
    How to get roll and pitch value from the game?
  10. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,520
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    144,950Coins
    Ratings:
    +10,770 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  11. balajee8848

    balajee8848 New Member

    Joined:
    Mar 12, 2021
    Messages:
    2
    Balance:
    - 14Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    2DOF
    • Like Like x 1
  12. Gadget999

    Gadget999 Well-Known Member

    Joined:
    Dec 27, 2015
    Messages:
    1,897
    Location:
    London
    Balance:
    11,610Coins
    Ratings:
    +458 / 9 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    is there a list of the available telemetry data ? for example rpm
  13. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,160
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,139Coins
    Ratings:
    +5,036 / 16 / -0
    It just depends on what the game has to offer.

    (unless i don't understand your question)
    Take care,
    yobuddy
  14. zhaoleon

    zhaoleon New Member

    Joined:
    Nov 17, 2021
    Messages:
    9
    Occupation:
    Simulation and VR development
    Location:
    China
    Balance:
    86Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    Motion platform, 6DOF
    I develop applications with unreal engine either,so glad to see the familiar code here.
    Maybe we can share the experience with unreal engine here.
    • Like Like x 1
  15. cth

    cth New Member

    Joined:
    Nov 24, 2021
    Messages:
    2
    Balance:
    12Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    6DOF
  16. cth

    cth New Member

    Joined:
    Nov 24, 2021
    Messages:
    2
    Balance:
    12Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    6DOF
    Can I refer to your complete script
  17. DOF_Dex

    DOF_Dex New Member Gold Contributor

    Joined:
    Jan 29, 2024
    Messages:
    17
    Location:
    London
    Balance:
    19Coins
    Ratings:
    +3 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, 6DOF
    Hi, I'm looking to recompile a UE4.18.1 plugin by Claudio Silva, to output to Unreal 5.3. The last Simtools UE4 plugin listed on Github was 2017, UE4.18.1 compatible. The only UE4 version available to download is 4.18.3. Unreal can get very picky even if its a .3 instead of .1.
    Any news on a new plugin update or I would be very grateful if anyone could help me with creating a link from UE to Simtools.

    Thank you
  18. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,520
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    144,950Coins
    Ratings:
    +10,770 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    The SimTools devs are pretty busy finalizing v3 for release, but once that is done perhaps @yobuddy could help you out.
    • Like Like x 1
  19. DOF_Dex

    DOF_Dex New Member Gold Contributor

    Joined:
    Jan 29, 2024
    Messages:
    17
    Location:
    London
    Balance:
    19Coins
    Ratings:
    +3 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, 6DOF
    I would be happy to rebuild each release (. point release) and keep the UE5 plugin maintained on Github. It would be great to see more Unreal users connecting to SimtoolsV3 in the future.
    I'm guessing the connection between UE5 and Simtools could be min 6 months away? Would the UE5 plugin need to built by the community or are there plans to update the UE5/simtools plugin by the @yobuddy and devs?
    I'm happy to test any alpha builds, sadly building a plugin from scratch linking to the new SimtoolsV3 is beyond my capabilities.
    Great to see the updated V3 Manual was released last week. @yobuddy and devs are doing great work. The UI is looking very slick.
  20. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,160
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    48,139Coins
    Ratings:
    +5,036 / 16 / -0
    There is no one way to do it. However your game sends the data, it's the job of the SimTools plugin to wrap around your game and deliver the telemetry to SimTools. So however you send the telemetry data will only change how the plugin for it receives the data and makes sense of it.
    Hope this helps buddy!
    • Like Like x 1
    Last edited: Feb 13, 2024