Board index FlightGear Support Multiplayer

Simulink, FlightGear, and Formation Flight  Topic is solved

Trouble getting online, setting up a server?
Forum rules
In order to help you, we need to know a lot of information. Make sure to include answers to at least the following questions in your initial post.

- what OS (Windows Xp/Vista, Mac etc.) are you running?
- what FlightGear version do you use?
- copy&paste your commandline.

Please, also see Requesting Technical Help.

Note: If you did not get a reponse, even after 7 days, you may want to check out the FlightGear mailing lists to ask your question there.

Simulink, FlightGear, and Formation Flight

Postby Tomas » Wed May 24, 2017 12:35 pm

Hello, everybody!
I am currently doing a project on formation flight control (Using Matlab Simulink) and trying to visualize the flight data with FlightGear. Following the post on wiki (http://wiki.flightgear.org/Howto:Multiplayer#Local_setup_for_testing), two instances are created but in each display window there is only one aircraft. (So instead of a pair of aircrafts flying in formation, there are two aircrafts flying lonely in each window.)

* Operating system: Windows 10, x64
* FlightGear version: v2016.1
* Commandline:
For lead aircraft in the formation:
Code: Select all
C:
cd C:\Program Files\FlightGear
SET FG_ROOT=C:\Program Files\FlightGear\data
.\\bin\fgfs --aircraft=X15 --fdm=network,localhost,5501,5502,5503 --start-date-lat=2016:06:01:12:00:00 --timeofday=noon --fog-fastest --disable-clouds --enable-sound --in-air --enable-freeze --airport=KSFO --runway=10L --altitude=110000*2/5 --heading=90 --offset-distance=0 --offset-azimuth=0 --enable-ai-models --multiplay=out,10,127.0.0.1,5000 --multiplay=in,10,127.0.0.1,5001 --callsign=Test1


For wing aircraft in the formation:
Code: Select all
C:
cd C:\Program Files\FlightGear
SET FG_ROOT=C:\Program Files\FlightGear\data
.\\bin\fgfs --aircraft=X15 --fdm=network,localhost,5501,5508,5503 --start-date-lat=2016:06:01:12:00:00 --timeofday=noon --fog-fastest --disable-clouds --enable-sound --in-air --enable-freeze --airport=KSFO --runway=10L --altitude=110000*2/5 --heading=90 --offset-distance=0 --offset-azimuth=0 --enable-ai-models --multiplay=out,10,127.0.0.1,5001 --multiplay=in,10,127.0.0.1,5000 --callsign=Test2


*Setting for "Send net_fdm Packet to FlightGear" in Simulink:
Lead aircraft:
Destination IP address: 127.0.0.1
Destination port: 5502
Sample time: 1/250

Wing aircraft:
Destination IP address: 127.0.0.1
Destination port: 5508
Sample time: 1/250

Could anyone find the problem or give any advice? Thanks~
Tomas
 
Posts: 9
Joined: Wed May 24, 2017 7:14 am

Re: Simulink, FlightGear, and Formation Flight

Postby AndersG » Wed May 24, 2017 12:46 pm

Can you test just the multiplay setup in isolation? E.g. using the standard c172p, there might be something odd when using the NetFDM.

I also think the "--fdm=network,localhost,5501,5508,5503" argument looks odd. As far as I can recall (I have not used this recently) there can only be one port and the next number after would be the expected rate.
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2414
Joined: Wed Nov 29, 2006 9:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: Simulink, FlightGear, and Formation Flight

Postby Tomas » Wed May 24, 2017 1:26 pm

Thank you for your timely reply.
I conducted a test replacing the "X15" model with a standard c172p model, the same problem seems to persist. The command lines are as follows:
Lead aircraft:
Code: Select all
C:
cd C:\Program Files\FlightGear

SET FG_ROOT=C:\Program Files\FlightGear\data
.\\bin\fgfs --aircraft=c172p --start-date-lat=2016:06:01:12:00:00 --timeofday=noon --fog-fastest --disable-clouds --enable-sound --in-air --enable-freeze --airport=KSFO --runway=10L --altitude=43970 --heading=90 --offset-distance=0 --offset-azimuth=0 --enable-ai-models --multiplay=out,10,127.0.0.1,5000 --multiplay=in,10,127.0.0.1,5001 --callsign=Test1


Wing aircraft:
Code: Select all
C:
cd C:\Program Files\FlightGear

SET FG_ROOT=C:\Program Files\FlightGear\data
.\\bin\fgfs --aircraft=c172p --start-date-lat=2016:06:01:12:00:00 --timeofday=noon --fog-fastest --disable-clouds --enable-sound --in-air --enable-freeze --airport=KSFO --runway=10L --altitude=44000 --heading=90 --offset-distance=0 --offset-azimuth=0 --enable-ai-models --multiplay=out,10,127.0.0.1,5001 --multiplay=in,10,127.0.0.1,5000 --callsign=Test2


For your second comment, it's actually from the help document of Matlab Simulink, and it worked fine in the simulation of each aircraft in the formation flight.

I guess the problem is on the communication between two FlightGear instances.
Last edited by Johan G on Sun May 28, 2017 8:22 pm, edited 1 time in total.
Reason: No need to quote the entire preceding post.
Tomas
 
Posts: 9
Joined: Wed May 24, 2017 7:14 am

Re: Simulink, FlightGear, and Formation Flight

Postby AndersG » Wed May 24, 2017 2:03 pm

It is odd that the stand-alone multiplayer test doesn't work. It is basically what I've used for years here.
Try different ports - you might have something that conflicts with port 5000 and 5001?
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2414
Joined: Wed Nov 29, 2006 9:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: Simulink, FlightGear, and Formation Flight

Postby Richard » Wed May 24, 2017 2:10 pm

When using FG on localhost you can have two aircraft maximum; the input and output ports need to be swapped, as below:

1. --multiplay=out,10,127.0.0.1,5001 --multiplay=in,10,,5000
2. --multiplay=out,10,127.0.0.1,5000 --multiplay=in,10,,5001

You can build and install fgms locally; in which case the output port would be the input port of fgms (usually 5000); and the input port (of flightgear) would be 5000 for the first instance, 5001 for the second, 5002 for the third (etc).

What's hard to figure out (but obvious when you have) is that the port you talk to fgms remains constant, but the port that fgms talks to FG needs to be unique for each instance (IP address/NAT).
Richard
 
Posts: 645
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10

Re: Simulink, FlightGear, and Formation Flight

Postby AndersG » Wed May 24, 2017 2:24 pm

I think they look properly swapped in the cited scripts above.
Another thing to check is if the Windows firewall gets involved.
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2414
Joined: Wed Nov 29, 2006 9:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: Simulink, FlightGear, and Formation Flight

Postby Tomas » Wed May 24, 2017 2:48 pm

Richard wrote in Wed May 24, 2017 2:10 pm:When using FG on localhost you can have two aircraft maximum; the input and output ports need to be swapped, as below:

1. --multiplay=out,10,127.0.0.1,5001 --multiplay=in,10,,5000
2. --multiplay=out,10,127.0.0.1,5000 --multiplay=in,10,,5001

You can build and install fgms locally; in which case the output port would be the input port of fgms (usually 5000); and the input port (of flightgear) would be 5000 for the first instance, 5001 for the second, 5002 for the third (etc).

What's hard to figure out (but obvious when you have) is that the port you talk to fgms remains constant, but the port that fgms talks to FG needs to be unique for each instance (IP address/NAT).


Thanks. But I think the ports I used are swapped as you have suggested.
Or do I misunderstand what you have said? Since I'm not quite sure about the meaning of "the port you talk to fgms remains constant".

What's more, since I just need two aircrafts in the visualization, I prefer to do this via a local network over the method which requires the setting up of a multiplay server. (To save some work and time)
Tomas
 
Posts: 9
Joined: Wed May 24, 2017 7:14 am

Re: Simulink, FlightGear, and Formation Flight

Postby Tomas » Wed May 24, 2017 2:49 pm

AndersG wrote in Wed May 24, 2017 2:03 pm:It is odd that the stand-alone multiplayer test doesn't work. It is basically what I've used for years here.
Try different ports - you might have something that conflicts with port 5000 and 5001?


That maybe the case. I will also try the case on another computer in my lab. Thanks :D
Tomas
 
Posts: 9
Joined: Wed May 24, 2017 7:14 am

Re: Simulink, FlightGear, and Formation Flight

Postby Richard » Wed May 24, 2017 4:06 pm

I've just tested this and the following two command lines work perfectly. The only difference is that the server isn't defined on multiplay=in - don't know if this is important or not - having tested it works both ways here.

I:\dev\flightgear\MSVC_3RDPARTY_ROOT\3rdParty.x64/bin/fgfs.exe "--fg-root=e:\temp\fgdata" --fg-aircraft=i:/fgaddon/trunk/aircraft "--aircraft=f15d" "--callsign=Rich1" "--multiplay=out,10,127.0.0.1,5000" "--multiplay=in,10,,5001"

I:\dev\flightgear\MSVC_3RDPARTY_ROOT\3rdParty.x64/bin/fgfs.exe "--fg-root=e:\temp\fgdata" --fg-aircraft=i:/fgaddon/trunk/aircraft "--aircraft=f15d" "--callsign=Rich2" "--multiplay=out,10,127.0.0.1,5001" "--multiplay=in,10,,5000"

at this point the best option would be to ensure that you haven't got a firewall interfering with things; and maybe some extra debugging --log-level=debug --log-class=network

if that doesn't work put use a packet tracer to find out what's actually going over the network; as I suspect this is a network configuration issue. You might want to replace the loopback adapter with the IPV4 address; etc.
Richard
 
Posts: 645
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10

Re: Simulink, FlightGear, and Formation Flight

Postby Tomas » Thu May 25, 2017 3:56 am

This morning I reinstalled FlightGear to Disk D and rerun the simulaton with the windows firewall closed.
Following are the command lines used:
Instance 1:
Code: Select all
D:
cd D:\Programms\FlightGear
SET FG_ROOT=D:\Programms\FlightGear\data
.\\bin\fgfs --aircraft=X15 --fdm=network,127.0.0.1,5501,5502,5503 --enable-ai-models --multiplay=out,10,127.0.0.1,5000 --multiplay=in,10,,5001 --callsign=Test1 --log-level=debug --log-class=network --start-date-lat=2016:06:01:12:00:00 --timeofday=noon --fog-fastest --disable-clouds --disable-sound --in-air --enable-freeze --airport=KSFO --runway=10L --altitude=110000*2/5 --heading=90 --offset-distance=0 --offset-azimuth=0


Instance 2:
Code: Select all
D:
cd D:\Programms\FlightGear
SET FG_ROOT=D:\Programms\FlightGear\data
.\\bin\fgfs --aircraft=X15 --fdm=network,localhost,5507,5508,5509 --enable-ai-models --multiplay=out,10,127.0.0.1,5001 --multiplay=in,10,,5000 --callsign=Test2 --log-level=debug --log-class=network --start-date-lat=2016:06:01:12:00:00 --timeofday=noon --fog-fastest --disable-clouds --disable-sound --in-air --enable-freeze --airport=KSFO --runway=10L --altitude=110000*2/5 --heading=90 --offset-distance=0 --offset-azimuth=0


Again, each aircraft flied well in each instance, they just don't show up together.

Here are the information concerning the nerwork activity found in the log file:
Code: Select all
network:3:..\..\..\flightgear\src\MultiPlayer\multiplaymgr.cxx:544:FGMultiplayMgr - have server
network:3:..\..\..\flightgear\src\MultiPlayer\multiplaymgr.cxx:561:FGMultiplayMgr::init-txaddress= 127.0.0.1
network:3:..\..\..\flightgear\src\MultiPlayer\multiplaymgr.cxx:562:FGMultiplayMgr::init-txport= 5001
network:3:..\..\..\flightgear\src\MultiPlayer\multiplaymgr.cxx:563:FGMultiplayMgr::init-rxaddress=
network:3:..\..\..\flightgear\src\MultiPlayer\multiplaymgr.cxx:564:FGMultiplayMgr::init-rxport= 5000
network:3:..\..\..\flightgear\src\MultiPlayer\multiplaymgr.cxx:565:FGMultiplayMgr::init-callsign= Test2
network:5:..\..\..\flightgear\src\MultiPlayer\multiplaymgr.cxx:588:Multiplayer mode active!


Does the log file indicate anything wrong with the simulation?

The whole log file texts can also be found from the link below for your reference:
http://pan.baidu.com/s/1jIQKpoE

P.S. The network adapter on the computer is "Intel(R) Ethernet Connection I217-LM", and it's on an IPV 4 network.
Last edited by Johan G on Sun May 28, 2017 8:24 pm, edited 1 time in total.
Reason: No need to quote the entire preceding post.
Tomas
 
Posts: 9
Joined: Wed May 24, 2017 7:14 am

Re: Simulink, FlightGear, and Formation Flight  

Postby Richard » Thu May 25, 2017 7:40 am

isNonBlockingError: WSAGetLastError():10035

this means that no data has been received (it's not an error and I've recently changed it to be non reported); however it indicates that data isn't coming in at that point;

I'm assuming that you unfreeze the simulation (in the command lines freeze is set with --enable-freeze). No position data is transmitted when paused.

A packet trace (e.g. wireshark) will better let you see what packets are being transmitted.

Remember that 127.0.0.1 is a different adapter than the IP that will be associated with your "Intel(R) Ethernet Connection I217-LM".

At this point I'm still of the opinion that it is likely to be a network / firewall configuration issue, based on what's reported, my testing and examination of the log file.
Richard
 
Posts: 645
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10

Re: Simulink, FlightGear, and Formation Flight

Postby Tomas » Thu May 25, 2017 9:52 am

Richard wrote in Thu May 25, 2017 7:40 am:isNonBlockingError: WSAGetLastError():10035

Thank you for pointing that out for me.

Richard wrote in Thu May 25, 2017 7:40 am:I'm assuming that you unfreeze the simulation (in the command lines freeze is set with --enable-freeze). No position data is transmitted when paused.

This indeed is the case. After removing "--enable-freeze" from the script, the communication between the two instances is recovered. And in each instance are two aircrafts flying in formation.

The only problem now is that the image of the 'guest' aircraft in each instance keeps moving back and forth (oscillation) quickly and the 'host' aircraft is stable in the center of the screen. It may be related to the frequency of the communication between the two instances or the setting of sampling time in Matlab Simulink (which sends the fdm data to FlightGear), and I am working on that.

The original problem is successfully solved. Thank you guys for your kind help!
Tomas
 
Posts: 9
Joined: Wed May 24, 2017 7:14 am

Re: Simulink, FlightGear, and Formation Flight

Postby Richard » Thu May 25, 2017 1:52 pm

The jitter experienced via Multiplay can be tuned using the lag settings from the multiplayer menu. (ref: http://wiki.flightgear.org/Multiplayer_ ... g_settings http://wiki.flightgear.org/Mp-patch)
Richard
 
Posts: 645
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10

Re: Simulink, FlightGear, and Formation Flight

Postby Richard » Thu May 25, 2017 2:07 pm

also setting both instances of FG to run at the same fixed frame rate will help stabilise things

--prop:/sim/frame-rate-throttle-hz=30

Use the debug menu "cycle on screen statistics" or --prop:/sim/rendering/on-screen-statistics=1 to show the frame rate in the top right. This should ideally never dip below the fixed value.
Richard
 
Posts: 645
Joined: Sun Nov 02, 2014 10:17 pm
Version: Git
OS: Win10

Re: Simulink, FlightGear, and Formation Flight

Postby Tomas » Fri May 26, 2017 4:55 pm

Thanks, Richard. I did as you suggested but the situation didn't seem to improve. Since the flight dynamic model was sent from Matlab Simulink, it was observed that the flickering of the 'guest' aircraft was related with the sampling rate setting in Simulink (the frequency at which the fdm data is transmitted). For example, when the sampling rate is set as 1Hz, the 'guest' aircraft will flicker at a rate of 1Hz.

I tried to increase the sampling rate in Simulink, however, the flickering first became more frequent, then the 'guest' aircraft just disappeared.

The lag of the local network (127.0.0.1) is less than 1ms. I made some attempts on the lag setting, but no good.
Last edited by Johan G on Sun May 28, 2017 8:25 pm, edited 1 time in total.
Reason: No need to quote the entire preceding post.
Tomas
 
Posts: 9
Joined: Wed May 24, 2017 7:14 am

Next

Return to Multiplayer

Who is online

Users browsing this forum: No registered users and 2 guests