1. 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!
  2. 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
  3. 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 Builder Gold Contributor

    Joined:
    Apr 15, 2015
    Messages:
    71
    Location:
    NE of YMML
    Balance:
    500Coins
    Ratings:
    +25 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino
    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:

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

    BrassEm G-Seat Builder Gold Contributor

    Joined:
    Apr 15, 2015
    Messages:
    71
    Location:
    NE of YMML
    Balance:
    500Coins
    Ratings:
    +25 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino
    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.

    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