DCS A10 Support?

Re: DCS A10 Support?

Postby asticher » Wed 24. Aug 2016, 11:12

Hello Folks,

I have still a big problem with the DCS Roll also called Bank Vektors.
I have to adjust the DCS Bank Export Value (Effekt 25) or alternative ac.Bank.
Reason: This DCS vector is a combined body frame vektor, but i need a fixed world frame vektor in order to get a prober 360° Bankangle in my MotionPit.
Elseway the bank vektor is turning upsidedown, when pitch reaches 90°.
Therefor i need to convert the bank angle. This is best done in the export.lua from DCS World.
First i read out the Eulerwinkel (XYZ) like this:

ac = LoGetSelfData(lACid)

bank = ac.Bank
pitch = ac.Pank
Yaw = ac.Heading

So we have our three body frame vektors.
No comes the tricky part. I testet a few formulas like this:

roll = (math.cos(ac.Pitch)) * ac.Bank
roll = math.cos(ac.Pitch) * ac.Bank
or
roll = ac.Bank * math.abs(math.cos(ac.Pitch))

But still the Bank angle flips at somehow at Pitch up 90°. I also tried without radiant converting vaktor with math.deg() .
And also tried with the original vektors (LoGetADIPitchBankYaw())
No Effekt, see also screenshots with vector vaults.

Has someone a clue?

André
Attachments
ac.Bank * math.cos(ac.Pitch)
cos Pitch
math.deg(ac.Bank) * math.deg(math.cos(ac.Pitch))
"No Brain, No Pain"

Intel i7; 16GB; Gigabyte Board; Nvidia GTX970Ci; Samsung SSD; TrackIR 5 Pro; NVidia 3D Vision, Thrustmaster Warthog with FFB; Logitech G25; DIY 360° 1DOF Motion Simulator; Lilliputs, Body Shaker + 5.1, Saitek Pro Pedals
User avatar
asticher
 
Posts: 72
Images: 18
Joined: Wed 5. Sep 2012, 20:18
Location: Germany near Munich
Has thanked: 2 times
Been thanked: 1 time

Re: DCS A10 Support?

Postby asticher » Sun 28. Aug 2016, 22:38

Update: i noted that the DCS vectors are not in equal formats. Some values are deg, some rad, some pos/neg, some abs.
In this case, ac.Bank and ac.Pitch are ...somewhat like radiant... :roll:
ac.Bank values goes from -3,14... to + 3,14 (1/2of full rad)
ac.Pitch goes from -1,57 to +1,57 (1/4 of full rad)
Therefor the Formula: bank * cos(pitch)
can´t work.
I need full radians from 0 to 6,28...
:!:
math.abs dosn´t solve this problem, because it only discard the minus-sign.
So how do i get a product of neg and pos values in lua???
PS: current (wrong) formula:
roll = math.abs(ac.Bank) * math.abs(math.cos(ac.Pitch * 2))
"No Brain, No Pain"

Intel i7; 16GB; Gigabyte Board; Nvidia GTX970Ci; Samsung SSD; TrackIR 5 Pro; NVidia 3D Vision, Thrustmaster Warthog with FFB; Logitech G25; DIY 360° 1DOF Motion Simulator; Lilliputs, Body Shaker + 5.1, Saitek Pro Pedals
User avatar
asticher
 
Posts: 72
Images: 18
Joined: Wed 5. Sep 2012, 20:18
Location: Germany near Munich
Has thanked: 2 times
Been thanked: 1 time

Re: DCS A10 Support?

Postby sirnoname » Mon 29. Aug 2016, 23:36

You have case switches in lua (if ...) thats how you have to work with 360° movements.
https://www.lua.org/pil/4.3.1.html
Normally you use old and a new value to decide the direction.
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1700
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 117 times

Re: DCS A10 Support?

Postby asticher » Wed 31. Aug 2016, 12:43

Ok, after some testing, BOSSHOG found out that all orientation DCS vectors do not following the common Euler sequence!
They never use Pitch up more then 90° (rad 1,57...) to achieve an absolut clear, objektdirection and position!
Therefor Yaw and Bank flipps upside down (180,0° / -180°) in the moment Pitch reaches > 90°
This is the true reason for this Bank "BUG"
Of course the formula bank * cos(pitch) don´t solve this problem anyway.
Another Bug: Because Pitch vectors don´t exceed 90° there is no Looping possible...if you pitch up AC nose more than 90°, then Pitch vectors go down to 0° instead of +180°.

To solve the problem we need to build in a 3x3 axis reverse rotation formula.
I could provide this Conversion in C++ from BOSSHOG.
But this won´t work in lua.
So now i need someone who build it into the DCS Import dll!
Last edited by asticher on Tue 6. Sep 2016, 22:55, edited 1 time in total.
"No Brain, No Pain"

Intel i7; 16GB; Gigabyte Board; Nvidia GTX970Ci; Samsung SSD; TrackIR 5 Pro; NVidia 3D Vision, Thrustmaster Warthog with FFB; Logitech G25; DIY 360° 1DOF Motion Simulator; Lilliputs, Body Shaker + 5.1, Saitek Pro Pedals
User avatar
asticher
 
Posts: 72
Images: 18
Joined: Wed 5. Sep 2012, 20:18
Location: Germany near Munich
Has thanked: 2 times
Been thanked: 1 time

Re: DCS A10 Support?

Postby BrassEm » Mon 5. Sep 2016, 04:31

asticher wrote:So now i need someone who build it into the DCS Import dll!


Many thanks for sharing your coding to try and resolve your problem. I am sure that if/then testing in the export.lua, although ugly, will do the job you need. Just need to test the previous value with the new value. If the differnce is great then a tumble has occured and adjust the value accordingly and send it out.

What is the C+ code from BOSSHOG? I am sure that the logic can be implemented in lua. Even if case is used.

(I will be needing derived rates of change for my application and will need to also resolve this issue. I will be coding for that now.)
User avatar
BrassEm
 
Posts: 13
Images: 66
Joined: Mon 16. Mar 2015, 01:28
Location: NE of YMML
Has thanked: 1 time
Been thanked: 0 time

Re: DCS A10 Support?

Postby asticher » Tue 6. Sep 2016, 10:46

:!: Yeah :!: standby...you´ll get PNs this week.
"No Brain, No Pain"

Intel i7; 16GB; Gigabyte Board; Nvidia GTX970Ci; Samsung SSD; TrackIR 5 Pro; NVidia 3D Vision, Thrustmaster Warthog with FFB; Logitech G25; DIY 360° 1DOF Motion Simulator; Lilliputs, Body Shaker + 5.1, Saitek Pro Pedals
User avatar
asticher
 
Posts: 72
Images: 18
Joined: Wed 5. Sep 2012, 20:18
Location: Germany near Munich
Has thanked: 2 times
Been thanked: 1 time

Re: DCS A10 Support?

Postby RiftFlyer » Fri 9. Sep 2016, 17:59

I am struggling with the established rotation outputs for my G-Seat project as well. I managed to output a force based on the rate of change of roll angle as an alternative but I'm not completely happy with it yet. I've experimented with slipball in place of yaw also. I've been using other software for motion but want to try and contribute here so we can all get a working lua solution for DCS.

One bit of software which seems to have solved the problem is TacView. It manages to display the orientation and attitude changes of the player aircraft in 3d space. I think that close inspection of the lua code it uses may help us in our quest.

http://lomac.strasoftware.com/download/ ... ortDCS.lua

Some snipets of interest here:

Code: Select all
-- Fix Yaw (because FC/BS map is a 2D projection, not a true 3D sphere)
   FixedYaw=function(Yaw,RefX,RefZ,Latitude,Longitude)

      -- Calculate vector to north in Lock-On coordinates
      local ToNorthPos=LoGeoCoordinatesToLoCoordinates(Longitude,Latitude+1);

      local ToNorthX=ToNorthPos.z-RefZ;
      local ToNorthY=ToNorthPos.x-RefX;

      local ToNorthLength=math.sqrt(ToNorthX*ToNorthX+ToNorthY*ToNorthY);

      -- Normalize vector
      if ToNorthLength>0 then

         ToNorthX=ToNorthX/ToNorthLength;
         ToNorthY=ToNorthY/ToNorthLength;

      end

      -- Calculate Yaw Error
      return Yaw+math.atan2(ToNorthY,ToNorthX)-math.pi/2;
   end,


Code: Select all
-- Update one object
   UpdateObject=function(self,ID,CurrentObjectData,ObjectType,PrevObjectData,FormatedTime,ShouldUpdateLog)

      -- Log object dynamic properties
      local ChangeDetected=false;
      local LogWasUpdated=false;
      local Log="";

      -- Latitude
      if not PrevObjectData or CurrentObjectData.LatLongAlt.Lat~=PrevObjectData.LatLongAlt.Lat then
         Log=Log..string.format(",%.6f",CurrentObjectData.LatLongAlt.Lat-self.LatitudeOffset);
         ChangeDetected=true;
      else
         Log=Log..",";
      end

      -- Longitude
      if not PrevObjectData or CurrentObjectData.LatLongAlt.Long~=PrevObjectData.LatLongAlt.Long then
         Log=Log..string.format(",%.6f",CurrentObjectData.LatLongAlt.Long-self.LongitudeOffset);
         ChangeDetected=true;
      else
         Log=Log..",";
      end

      -- Altitude
      if not PrevObjectData or CurrentObjectData.LatLongAlt.Alt~=PrevObjectData.LatLongAlt.Alt then
         Log=Log..string.format(",%.2f",CurrentObjectData.LatLongAlt.Alt);
         ChangeDetected=true;
      else
         Log=Log..",";
      end

      -- Roll/Pitch/Yaw
      if self.IsSimpleObject(ObjectType)==true then   -- shell/bullet/ballistic-shell/flare/chaff/smoke-grenade/cartridge

         -- Do not log roll/pitch/yaw to reduce recording size
         Log=Log.."\n";

      elseif ObjectType==0x46 or (ObjectType==0x4c and CurrentObjectData.Name=="") then   -- bombs without names => bomblets

         -- Emulate bomblets and shrapnel orientation
         if not PrevObjectData then
            Log=Log..",?,?,?\n";
         else
            Log=Log.."\n";
         end

      else

         -- Roll
         if not PrevObjectData or CurrentObjectData.Bank~=PrevObjectData.Bank then

            local NewFormatedRoll=string.format(",%.1f",math.mod(math.deg(CurrentObjectData.Bank),360));
            local RollIsDifferent=true;

            if PrevObjectData then

               local OldFormatedRoll=string.format(",%.1f",math.mod(math.deg(PrevObjectData.Bank),360));

               if NewFormatedRoll==OldFormatedRoll then
                  RollIsDifferent=false;
               end
            end

            if RollIsDifferent==true then
               Log=Log..NewFormatedRoll;
               ChangeDetected=true;
            else
               Log=Log..",";      -- not different enough to be dumped
            end

         else
            Log=Log..",";
         end

         -- Pitch
         if not PrevObjectData or CurrentObjectData.Pitch~=PrevObjectData.Pitch then

            local NewFormatedPitch=string.format(",%.1f",-math.mod(math.deg(-CurrentObjectData.Pitch),360));
            local PitchIsDifferent=true;

            if PrevObjectData then

               local OldFormatedPitch=string.format(",%.1f",-math.mod(math.deg(-PrevObjectData.Pitch),360));

               if NewFormatedPitch==OldFormatedPitch then
                  PitchIsDifferent=false;
               end
            end

            if PitchIsDifferent==true then
               Log=Log..NewFormatedPitch;
               ChangeDetected=true;
            else
               Log=Log..",";      -- not different enough to be dumped
            end

         else
            Log=Log..",";
         end

         -- Yaw
         if not PrevObjectData or CurrentObjectData.Heading~=PrevObjectData.Heading then

            local NewFormatedYaw=string.format(",%.1f\n",math.mod(math.deg(Tacview.FixedYaw(CurrentObjectData.Heading,CurrentObjectData.Position.x,CurrentObjectData.Position.z,CurrentObjectData.LatLongAlt.Lat,CurrentObjectData.LatLongAlt.Long)),360));
            local YawIsDifferent=true;

            if PrevObjectData then

               local OldFormatedYaw=string.format(",%.1f\n",math.mod(math.deg(Tacview.FixedYaw(PrevObjectData.Heading,PrevObjectData.Position.x,PrevObjectData.Position.z,PrevObjectData.LatLongAlt.Lat,PrevObjectData.LatLongAlt.Long)),360));

               if NewFormatedYaw==OldFormatedYaw then
                  YawIsDifferent=false;
               end
            end

            if YawIsDifferent==true then
               Log=Log..NewFormatedYaw;
               ChangeDetected=true;
            else
               Log=Log..",\n";      -- not different enough to be dumped
            end

         else
            Log=Log..",\n";
         end
      end

      -- Advanced Telemetry
      local AdvancedLog="";
      local AdvancedLogChangeDetected=false;

      if self.IsSimpleObject(ObjectType)==false and ObjectType~=0x46 and ObjectType<0x80 then

         -- 0: X,Y,Yaw (from: z,x)
         if not PrevObjectData or CurrentObjectData.Position.z~=PrevObjectData.Position.z or CurrentObjectData.Position.x~=PrevObjectData.Position.x or CurrentObjectData.Heading~=PrevObjectData.Heading then
            AdvancedLog=AdvancedLog..string.format(",,%.1f,%.1f,%.1f",CurrentObjectData.Position.z,CurrentObjectData.Position.x,math.mod(math.deg(CurrentObjectData.Heading),360));
            AdvancedLogChangeDetected=true;
         end


Of course there is lots going on in tacview that we don't need but perhaps someone proficient in lua could find something useful above.

Here is an example of the lua code I wrote to output a modified roll and yaw value. It outputs a value based on rate of change of angle rather than the angle itself. The yaw value flips with pitch so it still needs work. EDIT: I also found I needed to average the value to clean up the output as it was a little jumpy and is frame rate dependent. Unfortunately my seat is STILL not complete so my ability to test has been limited.

Code: Select all


function LuaExportStart()-- Works once just before mission start.

   default_output_file = io.open("./Export.log", "w")
   package.path = package.path..";.\\LuaSocket\\?.lua"
   package.cpath = package.cpath..";.\\LuaSocket\\?.dll"
   socket = require("socket")
   
   
      -- export telemetry.
      host1 = host1 or "127.0.0.1"
      port1 = port1 or 41230
      c = socket.udp ( )
      c:settimeout ( 0 )
      c:setpeername ( host1, port1 )   
   
end


-- Global variables.
beforeTime = nil
beforeBankAngle = nil
beforeYawAngle = nil
rollRate_table ={}
yawRate_table = {}


function LuaExportBeforeNextFrame()-- Run before the next frame.
   
   beforeTime = LoGetModelTime()
    local pitch, bank, yaw = LoGetADIPitchBankYaw()
    beforeBankAngle = bank/math.pi*180
   beforeYawAngle = yaw/math.pi*180
   
      
   function meanRollRate() -- used to average the values of the roll rate in order to provide a cleaner output.
      table.insert(rollRate_table, 1, rollRate)
      count = 0
      for _ in pairs(rollRate_table) do
      count = count +1
      end
      sum = 0
      for k,v in pairs(rollRate_table) do
      sum = sum +v
      end
      if count == 6 then table.remove(rollRate_table)end
      meanrollrate = (sum/count)
      return meanrollrate
   end
   
   function meanYawRate() -- used to average the values of the yaw rate in order to provide a cleaner output.
      table.insert(yawRate_table, 1, yawRate)
      count = 0
      for _ in pairs(yawRate_table) do
      count = count +1
      end
      sum = 0
      for k,v in pairs(yawRate_table) do
      sum = sum +v
      end
      if count == 6 then table.remove(yawRate_table)end
      meanyawrate = (sum/count)
      return meanyawrate
   end
end

function LuaExportAfterNextFrame()-- Run after next frame.

   local deltaTime = LoGetModelTime() - beforeTime
    local pitch, bank, yaw = LoGetADIPitchBankYaw()
    local deltaBankAngle = (bank/math.pi*180) - beforeBankAngle
      if deltaBankAngle < -180 then
         deltaBankAngle = deltaBankAngle + 360 end
      if deltaBankAngle > 180 then
         deltaBankAngle = deltaBankAngle - 360 end
   local deltaYawAngle = (yaw/math.pi*180) - beforeYawAngle
      if deltaYawAngle < -180 then
         deltaYawAngle = deltaYawAngle +360 end
      if deltaYawAngle >180 then
         deltaYawAngle = deltaYawAngle -360 end
    local t = LoGetModelTime()
   local altRad = LoGetAltitudeAboveGroundLevel()
   local accel = LoGetAccelerationUnits()
   
   
   yawRate = deltaYawAngle/deltaTime
   local user1 = meanYawRate() -- This outputs a force based on the current yaw rate of the aircraft. This can be used in place of yaw.
   rollRate = deltaBankAngle/deltaTime   
   local user2 = meanRollRate() -- This outputs a force based on the current roll rate of the aircraft. This can be used in place of roll.
   
   
   
   -- reduces forces on the ground.
   if altRad < 3 then
      accel.x = accel.x * 0.25
      accel.y = accel.y * 0.25
      accel.z = accel.z * 0.25
      user1 = user1 * 0.25
   end

   
   -- Output to Export.log file.
   --default_output_file:write(string.format("beforeTime:, %.4f, BeforeAngle:, %.4f, Time:, %.4f, Angle:, %.4f, rollRate, %.4f, Average:, %.4f\n", beforeTime, beforeBankAngle, t, bank/math.pi*180, rollRate, user2))
   --default_output_file:write(string.format("beforeTime:, %.4f, BeforeAngle:, %.4f, Time:, %.4f, Angle:, %.4f, yawRate, %.4f, Average:, %.4f\n", beforeTime, beforeYawAngle, t, yaw/math.pi*180, yawRate, user1))


   -- Output String.
   if c then
         socket.try(c:send(string.format("%.4f; %.4f; %.4f; %.4f; %.4f; %.4f; %.4f; %.4f;\n", pitch, bank, yaw, accel.x, accel.y, accel.z, user1, user2)))

   end
   

end



function LuaExportStop() -- Works once just after mission stop.
c:close()
      

if default_output_file then
default_output_file:close()
default_output_file = nil
end

end


Anyway we have plenty of like minded people who want to improve the DCS motion simulator experience so hopefully we can make some progress.
RiftFlyer
 
Posts: 29
Images: 22
Joined: Wed 23. Apr 2014, 22:20
Has thanked: 2 times
Been thanked: 0 time

Re: DCS A10 Support?

Postby asticher » Sun 11. Sep 2016, 22:52

Thanks RiftFlyer and BrassEM...we´re getting decent in this issue i guess :-)
I´m not a coder but i think RiftFlyer and Bosshogs intentions leading in the same direction (i´ll test the lua part from you very soon)

And so i just drop this C++ VS2013 sourcecode from bosshog here for download:
*Update: Link was send via PN
Open the Matrix.exe in Matrix\x64\Release\
It´s description four loops (each end of loop is a gey line) with wings level unchanged.
You see the blue line with org. DCS vectors and red line with the recalculated attitudes from bosshog...this seems perfect to me (for Bank and Pitch).
I´m pretty sure that Tacview use a similar matrix...meaning no lua solution.
Now the Details (translated from german as good as i can):

My solution beginning with the rotation-matrix did not work, because the back rotation goes back only about the given Attitude values.
This is due to the fact that the matrix also produces two or more possible sin/cos values of the one and same Attitude.

The solution is to recognise when the Yaw and Roll is flipping.
DCS has inserted a soft fading for the Pitch.
For YAW and Roll a jump of 180° has been embraced.

Pitch and Roll must cover the area from +/-180 degree for your Motion Simulator.
The function to be used for this, is called ConvertDCSattitude.
This function uses a comparative recognition.
Hence, the topical DCS vectors must be interstored and by the next call as "the preceding" values are handed over.

This is the only way to recognised the special situations (attitudes).

The conversion function uses a few auxiliary functions from "GEOMETRY Library".
I´ve added the functions source code.
Also the matrix functions is provided.

The source code may be transmitted to prospective customer.


Hope this will help somehow!

Ok
Attachments
"No Brain, No Pain"

Intel i7; 16GB; Gigabyte Board; Nvidia GTX970Ci; Samsung SSD; TrackIR 5 Pro; NVidia 3D Vision, Thrustmaster Warthog with FFB; Logitech G25; DIY 360° 1DOF Motion Simulator; Lilliputs, Body Shaker + 5.1, Saitek Pro Pedals
User avatar
asticher
 
Posts: 72
Images: 18
Joined: Wed 5. Sep 2012, 20:18
Location: Germany near Munich
Has thanked: 2 times
Been thanked: 1 time

Re: DCS A10 Support?

Postby esilv » Thu 22. Sep 2016, 23:58

Hello Everybody,
Sorry for my bad inglish.

I can't connect DCS World to X-SIM Extractor...
I tryed the classic way : adding my game my the Run.exe
Next, i tryed the notepad.exe way : whe i lunch the game by "Play Game" buttun, the notebad lunch well with the pluging LockOnPlug (Not connected), but when i lunch DCS, the plugin still not connected and when i play on DCS no DATA come in the Converter... :(

Why ? How Can I fixe this problem ?

I changed the extraction.lua file (maybe i used a bad one) but that change nothing...

Pleaz help me. :roll:

EDIT 1 : i fixed the "play game" buttun stay gray because i add the game with the folowing .exe file : C:\Program Files\Eagle Dynamics\DCS World\bin\DCS.exe :)
But the pluging still "no connection" and no DATA come to Convertor... :roll:
esilv
 
Posts: 4
Joined: Thu 22. Sep 2016, 14:00
Has thanked: 0 time
Been thanked: 0 time

Re: DCS A10 Support?

Postby asticher » Sun 25. Sep 2016, 14:36

1. install x-sim 3x and copy the DCS Plugin (dll and exe) in this path:
C:\Program Files (x86)\X-Sim\Plugin
2. Start extractor push left button "add yout game"
3. Choose "do not config, manuel setup" and open advanced setup
4. Enter "Converter.exe" under "locate your game executeable manually"
And add the DCSPlugin in the dropdown menu this dialog.
Confirme with Add this game...
5. In the right part of the extrator, click "game select" or "Used Game" and choose the converter also!!!
6. Start now the new profil with "Play Game" -> the DCS Plugin should pop-up and also the Converter
7. There after start DCS World and fly a mission.
8. In the DCS Pluging PopUp should now show values and also in the Converter Input section
Attachments
DCSPlugin.zip
DCS Plugin
(1.72 MiB) Downloaded 135 times
"No Brain, No Pain"

Intel i7; 16GB; Gigabyte Board; Nvidia GTX970Ci; Samsung SSD; TrackIR 5 Pro; NVidia 3D Vision, Thrustmaster Warthog with FFB; Logitech G25; DIY 360° 1DOF Motion Simulator; Lilliputs, Body Shaker + 5.1, Saitek Pro Pedals
User avatar
asticher
 
Posts: 72
Images: 18
Joined: Wed 5. Sep 2012, 20:18
Location: Germany near Munich
Has thanked: 2 times
Been thanked: 1 time

PreviousNext

Return to Digital Combat Simulator Series

Who is online

Users browsing this forum: No registered users and 1 guest