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 Now a Download Plan!
  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. 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

SimTools Presets DCS settings and export.lua

Discussion in 'Game Engine axes presets' started by Mikko Leino, Oct 16, 2020.

  1. Mikko Leino

    Mikko Leino New Member

    Joined:
    May 13, 2019
    Messages:
    3
    Occupation:
    Race Director
    Location:
    Finland
    Balance:
    128Coins
    Ratings:
    +2 / 0 / -0
    My Motion Simulator:
    4DOF
    Hi all

    Thought I'd share my export.lua, which I'm quite pleased with. I have added some functions that make especially heliopter flying more realistic and rich in feedback. I have a background in general aviation, mainly sailplanes. Therefore I really enjoy what Value1 and Dirty have done with the roll rate function, which is far more realistic than holding a steady tilt when banking / climbing. The AOA function is also great but I encountered serious problems with helicopters.

    When flying slowly or hovering, the AOA shifts abruptly between positive and negative values. For example, climbing / descending at slow speeds gives a value of anything between -90° and +90° AOA. Again, flying backwards outputs values from -90° to -180° and +90° to +180°. Flying backwards and transitioning from descent to climbing results in -180° to +180° jerk. Highly annoying and distracting.

    The export.lua I attached here outputs no AOA values at low airspeeds, but outputs pitch/bank rate values. While speed increases, the AOA values gradually increase and angle rates decrease. Works great on helos, and pulling high AOA manoeuvres in a MIG29 feel awesome :)

    Bear in mind, I am using Fasetech's RacingCube 4. I am no programmer, so tweak the code to your liking and please let me know how it feels on rigs with smaller range of motion. Have fun.

    Code:
    ---------------------------------------------------------------------------------------------------
    -- Experimental Export plugin for SimTools V2.35 (created by Value1, modified by Dirty)
    -- Version 0.05
    
    -- Added AOA speed & attitude sensitivity for choppers by Mikko
    ---------------------------------------------------------------------------------------------------
    
    
    Myfunction =
    {
    Start=function(self)
        package.path = package.path..";.\\LuaSocket\\?.lua"
        package.cpath = package.cpath..";.\\LuaSocket\\?.dll"
        socket = require("socket")
    
        my_init = socket.protect(function()
            -- export telemetry to SimTools
            host1 = host1 or "127.0.0.1"
            port1 = port1 or 41230
            c = socket.udp ( )
            c:settimeout ( 0 )
            c:setpeername ( host1, port1 )
        end)
        my_init()
    end,
    
    
    AfterNextFrame=function(self)
        --Euler Angles
        local mySelf = LoGetSelfData()
            local Yaw =     mySelf.Heading
            local Pitch =     mySelf.Pitch
            local Bank =     mySelf.Bank
        local accel = LoGetAccelerationUnits()
        local omega = LoGetAngularVelocity()
     
        --Air Data
        local IAS = LoGetIndicatedAirSpeed()
        local AOA = LoGetAngleOfAttack();
    
        --Weight On Wheels
        local LeftGear = LoGetAircraftDrawArgumentValue(6)
        local NoseGear = LoGetAircraftDrawArgumentValue(1)
        local RightGear = LoGetAircraftDrawArgumentValue(4)
     
        local OnGround = 0        --OnGround status is determined by the compression of ANY gear strut
        if (LeftGear > 0 or NoseGear > 0 or RightGear > 0)
            then
                OnGround = 1
            else
                OnGround = 0
        end
    
    
    --change exported values when on ground
        if (OnGround == 1) then
            accel.x = accel.x * 2.00
            accel.y = accel.y * 3.00
            accel.z = accel.z * 2.00
            omega.x = omega.x * 1.00
            omega.y = omega.y * 1.00
            omega.z = omega.z * 1.00
        end
     
     
    
    -- AOA AND PITCH FIX (For smooth chopper hover and natural pitch behaviour)
    
        --Pitch/AoA speed sensitivity
        local maxFXspd = 60.00
        local midFXspd = 30.00
        local minFXspd = 10.00
        local AOAspeedCoeff = math.min ( IAS - minFXspd , midFXspd ) / midFXspd
    
        if AOAspeedCoeff < 0
        then AOA = 0
    else
    AOA = AOA * AOAspeedCoeff
    
    end
    
        local PitchCoeff = math.min ( IAS , maxFXspd ) / maxFXspd
        
            if IAS > minFXspd
            then Pitch = Pitch * PitchCoeff
    end
     
        --Reverse flight & extreme AOA angle cancellation
        local AOApeak = 45
        local AOAfade = 80
     
        if AOA < -AOAfade then AOA = 0
        elseif AOA < -AOApeak then AOA=AOA+(2*AOApeak)
        elseif AOA < 0 then AOA = -AOA
    
        elseif AOA < AOApeak then AOA = AOA
        elseif AOA < AOAfade then AOA = 80 - AOA
        else AOA = 0
    end    
        --Roll rate speed sensitivity
        --local rollTreshLo = 350.00
        --local rollTreshMax = 900.00
        --local RRspeedCoeff = math.min ( IAS - rollTreshLo, rollTreshMax ) / rollTreshMax
    
        --if RRspeedCoeff < 0
        --then omega.z = 1
    
    --else    omega.z = omega.z * RRspeedCoeff + 0.2
    
    --end    
    
    
    
     
            
    
    
    
        --send data via UDP
        my_send = socket.protect(function()
            if c then
                socket.try(c:send(string.format("%.4f; %.4f; %.4f; %.4f; %.4f; %.4f; %.4f; %.4f; %.4f;\n", omega.x, omega.y, omega.z, accel.x, accel.y, accel.z, OnGround, IAS, AOA)))
    
                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
    end
    DCS tuning.png
    DCS axes1.png
    DCS axes2.png
    • Like Like x 1
    • Useful Useful x 1
    Last edited by a moderator: Oct 16, 2020
  2. Ads Master

    Ads Master

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
  3. Mikko Leino

    Mikko Leino New Member

    Joined:
    May 13, 2019
    Messages:
    3
    Occupation:
    Race Director
    Location:
    Finland
    Balance:
    128Coins
    Ratings:
    +2 / 0 / -0
    My Motion Simulator:
    4DOF
    Nice... the photos seem to have multiplied themselves, and I am not able to edit or delete the post anymore. Sorry...
  4. value1

    value1 Nerd Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Jan 9, 2011
    Messages:
    2,178
    Location:
    Zug, Switzerland
    Balance:
    9,267Coins
    Ratings:
    +3,229 / 11 / -1
    My Motion Simulator:
    2DOF, DC motor, JRK, Joyrider
    Fixed. Please check, if your code is still right.
    PS: To prevent spamming one can edit a post once you have posted enough (5?) posts.
    • Like Like x 1