Board index FlightGear Support Interfacing

FG and Simulink: Running issue

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

FG and Simulink: Running issue

Postby flyingpanther » Fri May 04, 2018 11:55 am


I am working on a visual flight analysis system using Matlab and FG. The idea is to take a flight log and visually see how the vehicle flew using FG.
I have successfully integrated FG with Simulink. However, once I start running FG, day and night starts rapidly changing. It obviously takes some duration of time as day, and night.
I have specified the time of day, time zone, etc, in BAT file. I have played with Simulation Rate and Time Warp. None has helped.
I am using FG 3.1 and Matlab R2015a. And, the input data to Simulink is in the form of a structure.

Any suggestion/idea on debugging this issue?

Posts: 2
Joined: Fri May 04, 2018 8:02 am

Re: FG and Simulink: Running issue

Postby Gijs » Mon May 07, 2018 11:00 am


Sounds like a nice project :-)
How do you feed your data from Matlab to FlightGear? Could you share the contents of your bat file?


PS: FlightGear 3.1 is pretty old by now (4+ years). Any particular reason why you cannot update or did you mean 2017.3.1?
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Posts: 9364
Joined: Tue Jul 03, 2007 2:55 pm
Location: Amsterdam/Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: FG and Simulink: Running issue

Postby flyingpanther » Tue May 08, 2018 8:47 am

The flight log data is processed in matlab and converted into the form of a struct with time. This data is captured from workspace by Simulink, and processed using components of inbuilt flight gear interfaces. The required data is finally sent to Flight Gear through 'Send net_fdm Packet to FlightGear' block. When the model is run, the aircraft does show the flight, and except for rapid day and night changes, it works fine. I use FG3.1 because that is the compatible version of FG for the version of Matlab that I use.
This is the content of my bat file:

cd C:\Program Files\FlightGear

SET FG_ROOT=C:\Program Files\FlightGear\data
.\\bin\win64\fgfs --aircraft=c172p --fdm=null --enable-auto-coordination --time-match-local --native-fdm=socket,in,30,localhost,5502,udp --fog-disable --enable-clouds3d --timeofday=noon --enable-sound --visibility=15000 --in-air --start-date-lat=2017:02:01:12:12.97:77.59 --enable-clock-freeze --prop:/engines/engine0/running=true --disable-freeze --airport=1Q4 --runway=12 --altitude=2000 --heading=0 --offset-distance=0 --offset-azimuth=0 --enable-rembrandt

I have tried options in 'timeofday', 'start-date-lat', 'clock-freeze', and 'time'.
I'm attaching my simulink model.

Posts: 2
Joined: Fri May 04, 2018 8:02 am

Re: FG and Simulink: Running issue

Postby daveculp » Tue May 08, 2018 9:43 pm

One of the values in the net_fdm structure is called "warp". The code comment says it's "offset in seconds to unix time", however it sounds like the other meaning of "warp" might be what it's really doing. I'd make sure it's getting a zero value.

Also, you have several time-related command line options. Maybe they don't work nicely together? I'd try just using one, like timeofday=noon
User avatar
Posts: 503
Joined: Sun Feb 24, 2013 1:50 am
Location: Las Vegas, USA
Callsign: DCulp
Version: 2017.3.1
OS: Ubuntu 17.10

Return to Interfacing

Who is online

Users browsing this forum: No registered users and 5 guests