Board index FlightGear Support Interfacing

Get data from FG to MATLAB

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

Get data from FG to MATLAB

Postby riccardo » Wed Sep 26, 2018 4:21 pm

Hi, is there a way to export data (speed, angle of attack, etc...) from FG to MATLAB in real time while the simulator is running?
I want to use that data to run some model identification algorithms in MATLAB.
riccardo
 
Posts: 3
Joined: Wed Sep 26, 2018 4:13 pm

Re: Get data from FG to MATLAB

Postby wlbragg » Wed Sep 26, 2018 5:38 pm

If you don't get anything specific, a quick search in forum/wik seems shows a lot of info on this subject.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7586
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Get data from FG to MATLAB

Postby riccardo » Wed Sep 26, 2018 8:39 pm

I found a lot of infos about how to visualise the MATLAB data in FG but not the other way around. Can you post some links? Thank you
riccardo
 
Posts: 3
Joined: Wed Sep 26, 2018 4:13 pm

Re: Get data from FG to MATLAB

Postby wlbragg » Wed Sep 26, 2018 8:43 pm

Sorry, I don't have time to do searches for other users. Maybe someone who has actually done this can point you to the correct data.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7586
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Get data from FG to MATLAB

Postby wkitty42 » Thu Sep 27, 2018 2:02 am

riccardo wrote in Wed Sep 26, 2018 4:21 pm:Hi, is there a way to export data (speed, angle of attack, etc...) from FG

you can export (aka log) values to CSV format... it is specific to each craft and defined in the craft's -set.xml file... i forget where i found the details on how to define the desired values to be logged but i was graphing similar to what you are looking for while working on a stall alarm for the c172p back when the c172p-detailed team formed... i do recall that i had to set the logging speed to something reasonable or there was either too much data or not enough... once a second might be workable depending on the level of detailed desired...

with that said, if MATLAB can read a CSV file, it should be workable for you...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Get data from FG to MATLAB

Postby riccardo » Thu Sep 27, 2018 8:13 am

I tried to enable logging but the app always crashes. I'm running version 2018.2.2 on macOS Mojave
riccardo
 
Posts: 3
Joined: Wed Sep 26, 2018 4:13 pm

Re: Get data from FG to MATLAB

Postby wkitty42 » Thu Sep 27, 2018 12:11 pm

we need more details than that, sir...

eg:
which version of FG?
which craft?
how did you try to enable logging?
what code did you add to the craft's -set.xml file?
how did the simulator crash?
what is the crash message?
did you get a core file that we can process?

the details are important... "my car won't start" doesn't tell us much... "my car won't start and the horn and lights do not work" is better and points to an electrical problem...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Get data from FG to MATLAB

Postby Ramanathan » Wed Oct 03, 2018 9:43 pm

I found the same issue with FG crashing on enabling logging.

I'm a windows 7 user.
I use FG 2018.2.2
I created an XML file and configured it to the command line and it got crashed
I also tried using the debug /logging option to generate the log, it crashed
It didn't throw any error but it just got closed abruptly

Please help me and I have pasted my XML settings for log

<?xml version="1.0"?>

-<PropertyList>


-<logging>


-<log>
<filename>1.csv</filename>

<enabled>true</enabled>

<interval-ms>100</interval-ms>

<delimeter>,</delimeter>


-<entry>

<enabled>true</enabled>

<title>Aileron</title>

<property>/controls/flight/aileron</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Elevator</title>

<property>/controls/flight/elevator</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Rudder</title>

<property>/controls/flight/rudder</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>flaps</title>

<property>/controls/flight/flaps</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Airspeed</title>

<property>/velocities/airspeed-kt</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Glideslope</title>

<property>/velocities/glideslope</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Altitude-agl-FT</title>

<property>/position/altitude-agl-ft</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Altitude-MSL-ft</title>

<property>/position/altitude-ft</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>VSI</title>

<property>/instrumentation/vertical-speed-indicator/indicated-speed-fpm</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Lat-Deg</title>

<property>/position/latitude-deg</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Long-Deg</title>

<property>/position/longitude-deg</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>AoA-degrees</title>

<property>/orientation/alpha-deg</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Heading-deg</title>

<property>/orientation/heading-deg</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>path-deg</title>

<property>/orientation/path-deg</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Pitch-deg</title>

<property>/orientation/pitch-deg</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Track-deg</title>

<property>/orientation/track-deg</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>GSNeedleDeflection</title>

<property>/instrumentation/nav/gs-needle-deflection-deg</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>GSNeedleDeflectionNorm</title>

<property>/instrumentation/nav/gs-needle-deflection-norm</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>LocNeedleDeflection</title>

<property>/instrumentation/nav/heading-needle-deflection</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>LocNeedleDeflectionNorm</title>

<property>/instrumentation/nav/heading-needle-deflection-norm</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Crosstrack-error</title>

<property>/instrumentation/nav/crosstrack-error-m</property>

</entry>


-<entry>

<enabled>true</enabled>

<title>Crosstrack-error-deg</title>

<property>/instrumentation/nav/crosstrack-heading-error-deg</property>

</entry>

</log>

</logging>

</PropertyList>
Ramanathan
 
Posts: 7
Joined: Mon Jun 04, 2018 10:32 pm

Re: Get data from FG to MATLAB

Postby wkitty42 » Sat Oct 06, 2018 4:53 pm

the 1st thing i see is that your starting tags seem to have a '-' in them that should not be there...
the 2nd this is it is very hard to read when not posted in code tags... the main thing is that code tags preserve formatting and spacing as well as using a mono-space font...
eg:
Code: Select all
[code]
your data here
  your data here
    your data here
  your data here
your data here
[/code]


i've cleaned your file up but not tested it... i use 2 spaces for each level of indention... you should also have seen errors written to the console or possibly even in the FG log file...

Code: Select all
<?xml version="1.0"?>
<PropertyList>
  <logging>
    <log>
      <filename>1.csv</filename>
      <enabled>true</enabled>
      <interval-ms>100</interval-ms>
      <delimeter>,</delimeter>
      <entry>
        <enabled>true</enabled>
        <title>Aileron</title>
        <property>/controls/flight/aileron</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Elevator</title>
        <property>/controls/flight/elevator</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Rudder</title>
        <property>/controls/flight/rudder</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>flaps</title>
        <property>/controls/flight/flaps</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Airspeed</title>
        <property>/velocities/airspeed-kt</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Glideslope</title>
        <property>/velocities/glideslope</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Altitude-agl-FT</title>
        <property>/position/altitude-agl-ft</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Altitude-MSL-ft</title>
        <property>/position/altitude-ft</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>VSI</title>
        <property>/instrumentation/vertical-speed-indicator/indicated-speed-fpm</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Lat-Deg</title>
        <property>/position/latitude-deg</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Long-Deg</title>
        <property>/position/longitude-deg</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>AoA-degrees</title>
        <property>/orientation/alpha-deg</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Heading-deg</title>
        <property>/orientation/heading-deg</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>path-deg</title>
        <property>/orientation/path-deg</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Pitch-deg</title>
        <property>/orientation/pitch-deg</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Track-deg</title>
        <property>/orientation/track-deg</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>GSNeedleDeflection</title>
        <property>/instrumentation/nav/gs-needle-deflection-deg</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>GSNeedleDeflectionNorm</title>
        <property>/instrumentation/nav/gs-needle-deflection-norm</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>LocNeedleDeflection</title>
        <property>/instrumentation/nav/heading-needle-deflection</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>LocNeedleDeflectionNorm</title>
        <property>/instrumentation/nav/heading-needle-deflection-norm</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Crosstrack-error</title>
        <property>/instrumentation/nav/crosstrack-error-m</property>
      </entry>
      <entry>
        <enabled>true</enabled>
        <title>Crosstrack-error-deg</title>
        <property>/instrumentation/nav/crosstrack-heading-error-deg</property>
      </entry>
    </log>
  </logging>
</PropertyList>



other than those '-' that were there, i don't find any mismatched tags...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Get data from FG to MATLAB

Postby Ramanathan » Wed Oct 17, 2018 5:28 pm

I have used the correct codes and added them to defaults.xml.
but if I enable logging which is if change my code to this: <enabled>true</enabled>, FG abruptly shutdown.
Can you please try to check if enabling logs is working fine in FG 2018 2.2 or anyother command line tags are required to work it out
Ramanathan
 
Posts: 7
Joined: Mon Jun 04, 2018 10:32 pm

Re: Get data from FG to MATLAB

Postby Ramanathan » Wed Oct 17, 2018 6:09 pm

I got figured out.
FG is blocking the creation of .csv file within its directory. I changed it to a different directory and got the csv file. Thanks anyways
Ramanathan
 
Posts: 7
Joined: Mon Jun 04, 2018 10:32 pm


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 1 guest