Board index FlightGear Support Interfacing

Interfacing Labview Inputs with FlightGear via UDP

Connecting two computers, using generic protocol, connecting with Matlab?

Interfacing Labview Inputs with FlightGear via UDP

Postby TheBasicTea » Tue Mar 23, 2021 10:33 am

Good morning FlightGear Community,
I have an own programmed FlightSimulation in LabView that needs to interface with FlightGear to visualize the whole thing.
Therefore I clicked myselfs through several FlightGear forum entries that gave me some clue how i can do that. I also read the I/O, Protocol READ.ME already.
Til now i was able to create xml.files in the "FlightGear 2020.3.6/data/Protocol" folder to bring me some Outputs from FlightGear to Labview, but I am really struggling with Inputs from LabView to Flight Gear. So lets give you clue how i am doing.

I adjusted the Flight Gear Settings like this.
Code: Select all
--httpd=5400
--props=5401

fgfs
--fdm=null
--model-hz=100
--generic=socket,in,100,127.0.0.1,48000,udp,02_elevator_in

--generic=socket,out,100,127.0.0.1,5600,udp,01_main_outputs
--generic=socket,out,100,127.0.0.1,1234,udp,01_altitude_pitch_elevator
--generic=socket,out,100,127.0.0.1,49000,udp,01_elevator_out

The last three entries for the FlightGear Output are working perfectly. (Thanks to the Community)
So i was able to read the strings and also put them into an array.

This is one example that just worked fine. "01_main_outputs"
Code: Select all
<?xml version="1.0"?>
<PropertyList>
<generic>
   <output>
      <line_separator>\n</line_separator>
      <var_separator>tab</var_separator>

      <chunk>
            <name>sent altitude </name>
            <node>/position/altitude-ft</node>
            <type>float</type>
            <format> Flughoehe (ueber MSL) = %06.6f ft\n</format>
      </chunk>
      <chunk>
            <name>altitude above ground</name>
            <node>/position/altitude-agl-ft</node>
            <type>float</type>
            <format>Flughoehe (agl) = %03.3f ft\n\n</format>
        </chunk>
      
      
      <chunk>
            <name>Anstellwinkel </name>
            <node>/orientation/alpha-deg</node>
            <type>float</type>
            <format>Anstellwinkel = %06.6f [Grad]\n</format>
        </chunk>
      <chunk>
            <name>roll / Rollwinkel </name>
            <node>/orientation/roll-deg</node>
            <type>float</type>
            <format>Rollwinkel = %06.3f [Grad]\n</format>
        </chunk>
        <chunk>
            <name>pitch / Nickwinkel </name>
            <node>/orientation/pitch-deg</node>
            <type>float</type>
            <format>Nickwinkel = %06.3f [Grad]\n</format>
        </chunk>
       <chunk>
            <name>yaw / Gierwinkel </name>
            <node>/orientation/yaw-deg</node>
            <type>float</type>
            <format>Gierwinkel = %06.6f [Grad]\n\n</format>
        </chunk>
      
        <chunk>
            <name>elevator position</name>
            <node>/surface-positions/elevator-pos-norm</node>
            <type>float</type>
            <format>Hoehenruderposition = %03.3f \n</format>
        </chunk>
      <chunk>
            <name>aileron left </name>
            <node>/surface-positions/left-aileron-pos-norm</node>
            <type>float</type>
            <format>Querruder (links) = %06.3f \n</format>
        </chunk>
      <chunk>
            <name>aileron right </name>
            <node>/surface-positions/right-aileron-pos-norm</node>
            <type>float</type>
            <format>Querruder (rechts) = %06.3f \n</format>
        </chunk>
      <chunk>
            <name>Seitenruder </name>
            <node>/surface-positions/rudder-pos-norm</node>
            <type>float</type>
            <format>Seitenruder = %06.3f \n\n</format>
        </chunk>

       <chunk>
          <name>airspeed-kt</name>
            <node>/velocities/airspeed-kt</node>
            <type>float</type>
            <format>Fluggeschwindigkeit(airspeed) = %06.3f [kt]\n</format>
          </chunk>
      
      <chunk>
          <name>groundspeed-kt</name>
            <node>/velocities/groundspeed-kt</node>
            <type>float</type>
            <format>Groundspeed = %06.3f [kt]\n\n</format>
          </chunk>
      
      <chunk>
          <name>Laengengrad</name>
            <node>/position/longitude-string</node>
            <type>string</type>
            <format>Laengengrad = %s \n</format>
          </chunk>
      
      <chunk>
          <name>Breitengrad</name>
            <node>/position/latitude-string</node>
            <type>string</type>
            <format>Breitengrad = %s \n\n</format>
          </chunk>
      
      <chunk>
          <name>true heading</name>
            <node>/orientation/true-heading-deg</node>
            <type>float</type>
            <format>true heading = %06.3f \n</format>
          </chunk>

      <chunk>
          <name>mag heading</name>
            <node>/orientation/heading-magnetic-deg</node>
            <type>float</type>
            <format>mag heading = %06.3f \n</format>
          </chunk>
   </output>
</generic>
</PropertyList>

Which gave me the following statement in Labview. So as you can see the Output is just working fine.
https://drive.google.com/file/d/1LkoSZ9wvEOLPMWglv_85KaUwefd_tQ_H/view?usp=sharing
Now lets switch to the harder part for me.
I created two another xml.files to listen to the elevator position and to the write to the elevator position. (The one that should listen to the elevator position is working)

The xml file for listening to the elevator postion "01_elevator_out"
Code: Select all
<?xml version="1.0"?>
<PropertyList>
    <generic>
        <output>
            <line_separator>\n</line_separator>
            <var_separator>/</var_separator>
         <chunk>
            <name>elevator position</name>
            <node>/surface-positions/elevator-pos-norm</node>
            <type>float</type>
            <format>%.6f</format>
        </chunk>
        </output>
    </generic>
</PropertyList>


The input elevator-position xml is this one "02_elevator_in"
Code: Select all
<?xml version="1.0"?>
<PropertyList>
    <generic>
        <input>
            <line_separator>\n</line_separator>
            <var_separator>/</var_separator>
         <chunk>
            <name>elevator position</name>
            <node>/surface-positions/elevator-pos-norm</node>
            <type>float</type>
            <format>%.6f</format>
        </chunk>
        </input>
    </generic>
</PropertyList>


I saw that the Output string from Flight Gear contains values with a "." as seperator instead of an ","
I already adjusted that for my output values.
Furthermore i saw that the incoming string from Flight Gear with the format "%.06" is 9 characters long and my string that i wanted to send to Flight Gear is 10 chracters long. I also adjusted that to the same format byshortening my Labview Output string to a lenght of 9.

This is my current vi. The Part where I am struggling with is the "Flight Gear Input" - While-Slope.
If you look at my vi you can also see that i tried to exchange my values with xplane which already worked out.
https://drive.google.com/file/d/1TSYwSqIL0pXFhODxNX1-XjU4oNJ4iHvK/view?usp=sharing

these are all elements are used so far summarized in a folder
https://drive.google.com/drive/folders/1cFUxNJflJVzKLqkaRdCl7JMuIRB-bXM1?usp=sharing

I don't know want else I can do and hope somebody can help me.
Many thanks in advance for your help.

Regards TheBasicTea
TheBasicTea
 
Posts: 1
Joined: Mon Mar 22, 2021 7:17 pm

Return to Interfacing

Who is online

Users browsing this forum: No registered users and 3 guests