HeliosVirtualCockpit / Helios

Helios Distribution
https://github.com/HeliosVirtualCockpit/Helios/wiki
GNU General Public License v3.0
204 stars 35 forks source link

Telemetry Driver and Interface: More DCS Simulator Telemetry for Helios #792

Open Shaftoe62 opened 9 months ago

Shaftoe62 commented 9 months ago

Hi,

Since I finally figured out how to edit (my own) HeliosExport16.lua to add the magnetic yaw to the common simulator telemetry, I went on a search for which other telemetry might be available.

I found a good source on Github which I will mention below.

But the main useful telemetry that could be added are these five:

local magneticyaw = LoGetMagneticYaw()
local tas = LoGetTrueAirSpeed()
local dcsModelTime = LoGetModelTime()
local missionStartTime = LoGetMissionStartTime()
local local windAloft = LoGetVectorWindVelocity() // this is an array to be processed as shown further down

It's also useful to use these new variables to pre-calculate the following additional variables:

--------------------------------------
local magneticvariance = yaw - magneticyaw // all three need to be converted from radians to degrees
--------------------------------------
local dcsTimeLocal = formatTime(LoGetMissionStartTime() + LoGetModelTime())

function formatTime(time)
    local delimiter = '-'
    local seconds = math.floor(time) % 60
    local minutes = math.floor(time / 60) % 60
    local hours = math.floor(time / (60 * 60)) % 24
    return string.format("%02d", hours) .. delimiter .. string.format("%02d", minutes) .. delimiter .. string.format("%02d", seconds)
end
--------------------------------------
local windStrength  = math.sqrt((windAloft.x)^2 + (windAloft.z)^2)
local windDirectionGeographicRad = math.atan2(windAloft.z, windAloft.x)

local windDirectionGeographic = math.deg(windDirectionGeographicRad)

if windDirectionGeographic < 0 then windDirectionGeographic = 360 + windDirectionGeographic
end
-- Convert to direction to from direction 
if windDirectionGeographic > 180 then windDirectionGeographic = windDirectionGeographic - 180
else windDirectionGeographic = windDirectionGeographic + 180
end

local windDirectionMagnetic = math.deg(windDirectionGeographicRad - magneticvariance)

if windDirectionMagnetic < 0 then windDirectionMagnetic = 360 + windDirectionMagnetic
end
-- Convert to direction to from direction 
if windDirectionMagnetic > 180 then windDirectionMagnetic = windDirectionMagnetic - 180
else windDirectionMagnetic = windDirectionMagnetic + 180
end

local windDirectionRelative = windDirectionGeographic - math.deg(yaw)
if windDirectionRelative < 0 then windDirectionRelative = 360 + windDirectionRelative end
if windDirectionRelative > 360 then windDirectionRelative = windDirectionRelative - 360 end

I send those variables to Helios as follows:

helios.send("T1", tonumber(string.format("%.2f",math.deg(pitch))))
helios.send("T2", tonumber(string.format("%.2f",math.deg(bank))))
helios.send("T3", tonumber(string.format("%.2f",math.deg(yaw))))
helios.send("T6", tonumber(string.format("%.2f",math.deg(magneticyaw))))

helios.send("S1", tonumber(string.format("%.2f",math.deg(magneticvariance))))

helios.send("S2", tas, "%.3f")
helios.send("S3", dcsModelTime, "%.2f")
helios.send("S4", dcsTimeLocal)

helios.send("S5", windDirectionGeographic)
helios.send("S6", windDirectionMagnetic)
helios.send("S7", windDirectionRelative)
helios.send("S8", windStrength)

Note: It would also be useful to add the other common telemetry like Air Temperature and Air Pressure to the section of the common DCS Simulator Telemetry as opposed to only in (for example) the aircraft Temperature Gauge and/or the Standby Altimeter.

That would improve the reusability of non-aircraft-specific panels or overlays.


I took my information from:

https://github.com/asherao/DCS-ExportScripts/blob/master/Scripts/DCS-ExportScript/ExportsModules/AH-64D_BLK_II.lua

There you can see that there is a lot more possible but I sticked to the primary telemetry for now.

BlueFinBima commented 9 months ago

Hi @Shaftoe62, apologies for the delay in getting back to you. I've been pretty ill recently. I'm certainly supportive of your efforts to use Helios for non-aircraft-specific purposes because it opens up a lot of interesting possibilities. The dilemma is to enable the new use-cases without adding significant additional cost to every user. An additional DCS interface would be the ideal mechanism, however Helios only supports profiles with a single DCS interface, and I don't have the bandwidth to prioritise the considerable work needed to remove this restriction. My current thinking is to load a new "DCSWorld" exit into the Lua (if it exists), and then have a number of non-specific input bindings in the DCS interfaces. The user can then add the data they want into these arguments within the exit. Thoughts?

Shaftoe62 commented 9 months ago

@BlueFinBima

Sorry to hear you've been ill. I was indeed wondering if something like that might be going on. Hope you are a bit better now.

I understand that you can't just "move" certain variables to the Simulator Telemetry. But I thought it might be useful to "also" have them available in the Simulator Telemetry Section.

But at this point I have no real general overview of how many of those cases exist.

On the other hand, I went through the ashero AH-64D_BLK_II.lua quite thoroughly and I think that with the telemetry I mentioned , most primary telemetry is quite well covered. And that would add only a limited amount (8) of variables to the Simulator Telemetry. Only two of which already exist in other sections.

But if I understand your idea correctly, you want to give users an option to create their own customized lua script that will be included during the generation of the HeliosExport16.lua file?

That would - of course - be an even more flexible option and that sounds like a good idea in any case.

I have actually been looking for that option in Helios but couldn't find it. So yes, I'm all for that.

But that might be complicated because you already have a lot of locally declared variables in your current functions.

If a user wants to (re) use these (like I do in the proposed pre-calculations) those user modifications in the newly included file, should be appended to those specific functions, I suppose?

That can be done - of course - but it has to be taken into account from the beginning.

The alternative would be to call the DCS functions (ie LoGetMagneticYaw etc) all over again and that sounds like a very bad idea.

BlueFinBima commented 9 months ago

Certainly an interesting idea, but where does the sucking of all possible information out of DCS and passing it to Helios actually end? Flagging for Fridge awaiting a skilled and motivated individual who is willing and more importantly able to properly investigate, assess the implications, (and possibly) implement and test such a change.

Shaftoe62 commented 9 months ago

As you can probably tell from all of my posts by now is that I really enjoy pushing the boundaries and use as much telemetry to my advantage as possible.

So for me it only ends when I'm sure there is no other telemetry left to squeeze out of DCS.

And now I have finally figured out how to add data to HeliosExport16.lua, I, for myself, am quite content.

I just thought it my be of use to share the things I learn here (or on Discord) while they are still fresh.

Another point is that there are many addons related to DCS (like the StreamDeck addon by asherao and many others) that all use different subsets of the telemetry. And his/her collection of Export modules is also a fork of earlier work by others.

The threat warning data we've been discussing in the other post, for instance, is overlooked (or neglected) by asherao.

So my quest for missing telemetry will go on for the foreseeable future, since there is no original source that contains it all...