1. Hundreds of coffees, endless nights of debugging and coding, and countless feedback by our beta testers led to this new major release. SimTools 2.4 is probably the version with the most upgrades and improvements in a single release ever. Look at everything Dustin has included:
    SimTools 2.4 all features.
    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 Download Package Now!
  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 here. Do not following these rules will lead to permanent exclusion from this website: Read the forum rules.

DCS g-seat plugin.

Discussion in 'Digital Combat Simulators (DCS)' started by BrassEm, Feb 9, 2018.

  1. BrassEm

    BrassEm G-Seat + SFX100 Builder Gold Contributor

    Joined:
    Apr 15, 2015
    Messages:
    96
    Location:
    NE of YMML
    Balance:
    747Coins
    Ratings:
    +36 / 0 / -0
    My Motion Simulator:
    DC motor, AC motor, 4DOF, 6DOF
    G'day,

    This plugin works for me and my g-seat setup. I've posted it so you can have a look and adapt it to your seat as needed. It is supplied "as is". I hope it works for you. If you do decide to try it, please make backups/notes before installing or changing anything so that you can recover your previous setup.

    The plugin.zip file installs how you normaly would do it, like any other plugin.

    Cheers,

    Brass.

    Attached Files:

    • Like Like x 1
    • Informative Informative x 1
    Last edited: Feb 9, 2018
  2. BrassEm

    BrassEm G-Seat + SFX100 Builder Gold Contributor

    Joined:
    Apr 15, 2015
    Messages:
    96
    Location:
    NE of YMML
    Balance:
    747Coins
    Ratings:
    +36 / 0 / -0
    My Motion Simulator:
    DC motor, AC motor, 4DOF, 6DOF
    After more testing I found that I had broken the outputs. It appears that the slip code causes an export.lua fault that stopped non-FC3 from working. I've removed that slip code and tested on 2.5 with Caucasus and Nevada okay. I am going to have to change the lurching levels for the prop planes though as they really rumble swinging the prop.

    You will need the manually add the code to your export.lua to correct the fault until I can recompile to Version 4.

    Fixed Export.lua to be added to _v04.
    Code:
    -------------------------------------------------------------------------------------------------------------------------------
    -- DCS Export Functions for use with SimTools motion control software for g-Seat use. Based on original Export.lua from value1.
    -- Version 0.04
    -- Author: BrassEm
    -- Take telemetry from DCS and convert to suitable data for Simtools.
    -- Many thanks to [FSF]Ian, Frusheen(RiftFlyer), Asticher(vJaBoG32), Andrey Filin from ED, yobuddy and value1 from XSimulator.
    -- It is assumed at this time that the g seat command is coming directly from the "accelerometers" in the aircraft.
    -- Forces in flight are Heave, Surge, Sway and Roll.
    -- Forces on ground are Pitch, Roll and Sway.
    -------------------------------------------------------------------------------------------------------------------------------
    
    -- Globals declared here
    PI = math.pi            -- 3.1415926535897932384626433832795028841971693993751
    HPI = PI/2                -- Radians in 90°
    PI2 = PI*2                -- Radians in 360°
    r2d = 180/PI            -- Radians to Degrees
    
    Myfunction =
    
    {
    Start=function(self)
    
        -- Output file to check values.
        default_output_file = io.open("./Export.log", "w")
      
        package.path = package.path..";.\\LuaSocket\\?.lua"
        package.cpath = package.cpath..";.\\LuaSocket\\?.dll"
        socket = require("socket")
    
        my_init = socket.protect(function()
            -- export telemetry to SimTools
            -- Setup comms for export telemetry to SimTools. Set host1 to your second PC IP.
            -- host1 = host1 or "19.190.26.5" -- Set to 127.0.0.1 for single PC or xxx.xxx.xxx.xxx for two PC's (Set to your 2nd PC IP)
            host1 = "19.190.26.5"     -- Mine in this case. Change it to yours.
            port1 = "41230"          
            c = socket.udp ( )
            c:settimeout ( 0 )
            c:setpeername ( host1, port1 )
    
        end)
        my_init()
    end,
    
    
    AfterNextFrame=function(self)
    
        -- Aircraft name
        local myInfo = LoGetSelfData()
        local CurrentAircraft = myInfo.Name
        -- Add additional telemetry values for testing purposes
        local altRad = LoGetAltitudeAboveGroundLevel()
        local TAS = LoGetTrueAirSpeed()  -- (args - 0, results - 1 (m/s))
    
        -- g Forces
        local accel = LoGetAccelerationUnits()      -- (args - 0, results - 1 (g)) The g-Force.
      
        -- From Frusheen
        local vel_v = LoGetVectorVelocity() -- (1 m/s), vel_v.x, vel_v.y, vel_v.z
        local vel_r = LoGetAngularVelocity() -- (radians per second), vel_r.x, vel_r.y, vel_r.z    = HUD Velocity Vector
      
        -- Output to SimTools
        local yaw = vel_r.y        -- Pitch > #2 in Sim Tools     - Tuning Center Output. beta plugin. Sway on ground.
        local roll = vel_r.x    -- Roll > #1 in Sim Tools     - Tuning Center Output. gamma plugin. Roll on ground.
        local pitch = vel_r.z    -- Yaw > #4 in Sim Tools     - Tuning Center Output. alpha plugin. Pitch on ground.
        local surge = accel.x    -- Surge > #6 in Sim Tools     - Tuning Center Output. Surge plugin .
        local heave = accel.y    -- Heave > #3 in Sim Tools     - Tuning Center Output. Heave plugin.
        local sway = accel.z    -- Sway > #5 in Sim Tools     - Tuning Center Output. Sway plugin.
        local slip = 0            -- Extra 1 > #7 in Sim Tools - Tuning Center Output. Aircraft slip. Not used.
        local roll_lurch = 0    -- Extra 2 > #8 in Sim Tools - Tuning Center Output. Aircraft lurching while on ground in roll.
        local pitch_lurch = 0    -- Extra 3 > #9 in Sim Tools - Tuning Center Output. Aircraft lurching while on ground in pitch.
      
        -- Convert Rates from radians into degrees.
        pitch = pitch*r2d
        roll = roll*r2d
        yaw = yaw*r2d
      
        -- Normalise Heave
        heave = heave-1  
    
        -- Add Aircraft lurching while on the ground.
        if altRad <= 2.5 then
                heave = 0
                pitch_lurch = pitch
                roll_lurch = roll
                roll = roll -- pitch = pitch, roll = bump, yaw = yaw.
                sway = yaw    -- yaw better than sway-accel.z.
            else
                pitch_lurch = 0
                roll_lurch = 0
                sway = yaw
        end
    
      
        -- Output Telemetry to Export.log file for testing purposes.
            default_output_file:write(string.format("AIRCRAFT: %s ALTRAD: %.2f TAS: %.1f PITCH: %.2f ROLL: %.2f YAW: %.2f SURGE: %.3f HEAVE: %.3f SWAY: %.3f SLIP: %.2f ROLL_LURCH: %.3f PITCH_LURCH: %.3f \n", CurrentAircraft, altRad, TAS, pitch, roll, yaw, surge, heave, sway, slip, roll_lurch, pitch_lurch))  
      
    
        my_send = socket.protect(function()
            if c then
                --    socket.try(c1:send(string.format("%.3f; %.3f; %.3f; %.3f; %.3f; %.3f;\n", pitch*1000.0, bank*1000.0, yaw*1000.0, accel.x*1000.0, accel.y*1000.0, accel.z*1000.0)))
                -- Simtools pitch, roll, yaw, surge, heave, sway, extra 1, extra 2, extra3
                socket.try(c:send(string.format("%.4f; %.4f; %.4f; %.4f; %.4f; %.4f; %.4f; %.4f; %.4f;\n", pitch, roll, yaw, surge, heave, sway, slip, roll_lurch, pitch_lurch)))
    
            end
        end)
        my_send()
    
    end,
    
    
    Stop=function(self)
        my_close = socket.protect(function()
            if c then
                c:close()
            end
        end)
        my_close()
    end
    }
    
    
    -- =============
    -- Overload
    -- =============
    
    -- Works once just before mission start.
    do
        local PrevLuaExportStart=LuaExportStart
        LuaExportStart=function()
            Myfunction:Start()
            if PrevLuaExportStart then
                PrevLuaExportStart()
            end
        end
    end
    
    -- Works just after every simulation frame.
    do
        local PrevLuaExportAfterNextFrame=LuaExportAfterNextFrame
        LuaExportAfterNextFrame=function()
            Myfunction:AfterNextFrame()
            if PrevLuaExportAfterNextFrame then
                PrevLuaExportAfterNextFrame()
            end
        end
    end
    
    -- Works once just after mission stop.
    do
        local PrevLuaExportStop=LuaExportStop
        LuaExportStop=function()
            Myfunction:Stop()
            if PrevLuaExportStop then
                PrevLuaExportStop()
            end
        end
        -- Close the output file
        if default_output_file then
            default_output_file:close()
            default_output_file = nil
        end
    end
    
    • Like Like x 2
    Last edited: Aug 6, 2019
  3. Jan Havranek

    Jan Havranek New Member Gold Contributor

    Joined:
    Sep 13, 2019
    Messages:
    12
    Balance:
    40Coins
    Ratings:
    +0 / 0 / -0
    Hi, I use your plugin on Gseat, works perfectly but I would like to do 2 dof seat. However, your plugin does not have the vectoring forces but only gforce, as described in the manual. Don't have an updated plugin version? Thanks a lot.
  4. BrassEm

    BrassEm G-Seat + SFX100 Builder Gold Contributor

    Joined:
    Apr 15, 2015
    Messages:
    96
    Location:
    NE of YMML
    Balance:
    747Coins
    Ratings:
    +36 / 0 / -0
    My Motion Simulator:
    DC motor, AC motor, 4DOF, 6DOF
    G'day Jan,

    Thanks for the feedback and glad it is working for you. Do you need to have 2 DOF output as well as Gseat?
  5. Jan Havranek

    Jan Havranek New Member Gold Contributor

    Joined:
    Sep 13, 2019
    Messages:
    12
    Balance:
    40Coins
    Ratings:
    +0 / 0 / -0
    Yes, if I make a pitch and roll only g-force on the seat, excuse me for English.
  6. Jan Havranek

    Jan Havranek New Member Gold Contributor

    Joined:
    Sep 13, 2019
    Messages:
    12
    Balance:
    40Coins
    Ratings:
    +0 / 0 / -0
    need g forces for the gseat plus 2 more vectored pitch and roll for the 2 DOF motors, yes...exactly, Thank you for your time
  7. BrassEm

    BrassEm G-Seat + SFX100 Builder Gold Contributor

    Joined:
    Apr 15, 2015
    Messages:
    96
    Location:
    NE of YMML
    Balance:
    747Coins
    Ratings:
    +36 / 0 / -0
    My Motion Simulator:
    DC motor, AC motor, 4DOF, 6DOF
    OK, will check the code to see if it is possible.
  8. Jan Havranek

    Jan Havranek New Member Gold Contributor

    Joined:
    Sep 13, 2019
    Messages:
    12
    Balance:
    40Coins
    Ratings:
    +0 / 0 / -0
    Thank you very much
  9. BrassEm

    BrassEm G-Seat + SFX100 Builder Gold Contributor

    Joined:
    Apr 15, 2015
    Messages:
    96
    Location:
    NE of YMML
    Balance:
    747Coins
    Ratings:
    +36 / 0 / -0
    My Motion Simulator:
    DC motor, AC motor, 4DOF, 6DOF
    G'day Jan,

    Unfortunately the short term answer is no, it is not possible with the way I have coded for this plugin. It was purely for g-seat output only, and adapted to get around some of the issues I was having with DCS.

    The good news is that I will very shortly be facing the very same issue where I need a normalised output for a 4DOF (2DOF in your case) motion platform plus pure accelerometer g vector output for the g-seat on top of it. I cannot foresee me getting to redo the plugin for a month or two. But it will be programmed for this setup. There is an anticipated SIMTOOLS configuration on the main page of my website for how the plugin is to be coded. Once it is working I will most definitely post it here if I can.
    • Like Like x 1
  10. Jan Havranek

    Jan Havranek New Member Gold Contributor

    Joined:
    Sep 13, 2019
    Messages:
    12
    Balance:
    40Coins
    Ratings:
    +0 / 0 / -0
    Hi, thank you for your time, while I will fly without pitch and roll and wait, thank you again and look forward to it.