Board index FlightGear Support Multiplayer

Jitter when having two flight gear instances on local machin

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.

Jitter when having two flight gear instances on local machin

Postby ma15rysi » Fri Dec 11, 2020 5:49 pm

Hi to everyone,

I am trying to control two planes from two FG instances at the same time to simulate coordinated maneuvers on my computer. To not disturb any public FGMS I use my own computer e.g. localhost as a server. I want to control both instances from Simulink. I managed to control both planes at the same time from Simulink and I also managed to visualize both plane in both instances (i.e. the communication between the two instances actually works) but as soon as I start my simulation, the plane that does not originally belong to the respective FG instance appears very jittery whereas the original plane that does not come via the multiplayer server works very smoothly. It seems like FG has a problem with sending or receiving the data. I use the following command lines for my two planes:
Plane 1: --fdm=network,localhost,5501,5502,5503 --multiplay=out,10,127.0.0.1,5000 --multiplay=in,10,127.0.0.1,5001 --callsign=Test1
Plane 2: --fdm=network,localhost,5501,5503,5503 --multiplay=out,10,127.0.0.1,5001 --multiplay=in,10,127.0.0.1,5000 --callsign=Test2

Is there anyone out there you can also relate to that problem or anyone who might know a solution? I would be very thankful!

Cheers
ma15rysi
 
Posts: 10
Joined: Fri Dec 11, 2020 5:22 pm

Re: Jitter when having two flight gear instances on local ma

Postby wkitty42 » Sat Dec 12, 2020 1:00 pm

ma15rysi wrote in Fri Dec 11, 2020 5:49 pm:Plane 1: --fdm=network,localhost,5501,5502,5503 --multiplay=out,10,127.0.0.1,5000 --multiplay=in,10,127.0.0.1,5001 --callsign=Test1
Plane 2: --fdm=network,localhost,5501,5503,5503 --multiplay=out,10,127.0.0.1,5001 --multiplay=in,10,127.0.0.1,5000 --callsign=Test2

is there a typo in one of the above two lines? one has a port duplicated...
"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: 6960
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Jitter when having two flight gear instances on local ma

Postby ma15rysi » Sat Dec 12, 2020 4:11 pm

Tbh, I don't really know what exactly the three ports in the '--fdm=network,localhost,5501,5502,5503' command do. They were autogenerated by Simulink and I found out that the middle port is for receiving the package data from the Simulink simulation. So, it was not a typo, but I also changed it and tried it with the following configurations.
Plane 1: --fdm=network,localhost,5501,5502,5503 --multiplay=out,10,127.0.0.1,5000 --multiplay=in,10,127.0.0.1,5001 --callsign=Test1
Plane 2: --fdm=network,localhost,5507,5508,5509 --multiplay=out,10,127.0.0.1,5001 --multiplay=in,10,127.0.0.1,5000 --callsign=Test2

I tried as well:
Plane 1: --fdm=null --native-fdm=socket,in,30,localhost,5502,udp --multiplay=out,10,127.0.0.1,5000 --multiplay=in,10,127.0.0.1,5001 --callsign=Test1
Plane 2: --fdm=null --native-fdm=socket,in,30,localhost,5503,udp --multiplay=out,10,127.0.0.1,5001 --multiplay=in,10,127.0.0.1,5000 --callsign=Test2

Both cases had the same jittery outcome...
ma15rysi
 
Posts: 10
Joined: Fri Dec 11, 2020 5:22 pm

Re: Jitter when having two flight gear instances on local ma

Postby Gijs » Sat Dec 12, 2020 4:47 pm

Hi,

I'll see if I can replicate this on my system tomorrow.

In the mean time, did you try adjusting the frequencies? I note that you're using 30 Hz for the native fdm (although that also depends on the output rate from Simulink) and 10 Hz for the multiplayer. Maybe this discrepancy causes some jittering?

Gijs

PS: --fdm=network,localhost,5501,5502,5503 is not a valid command (see http://wiki.flightgear.org/MATLAB#Bug_i ... Run_Script)
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9361
Joined: Tue Jul 03, 2007 2:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Jitter when having two flight gear instances on local ma

Postby wkitty42 » Sun Dec 13, 2020 2:42 pm

i wrote about the data speed in a reply to a similar (but seven year old) topic just a little bit ago...
wkitty42 wrote in Sun Dec 13, 2020 1:53 pm:if it were me, i'd look at the timing of the data being sent to FG... perhaps FG is updating faster than the data is sent? or perhaps there's multiple updates in a row with the same data instead of only the changed data being sent... but this is just an eWAG looking on from the outside...
"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: 6960
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Jitter when having two flight gear instances on local ma

Postby jano » Sun Dec 13, 2020 9:15 pm

Hi, that's not a problem from your config and it has been reported here before:), it come from the crude way we use net fdm input in FG, basically we display the plane at the last position received from the netfdm without any time interpolation, if you have low sending rate, few frame will have a plane with the same position, giving a not very smooth visual, and the other plane coming from the mp protocol will have a different behavior, the two planes together will be jitterly. this is more obvious in external view from above, you'll see the ground moving in a jumpy way , change view for the mp plane and see if it's the same .
with that config, you can try to limit fg frame rate, send from simulink at same or higher frequency (x2, x3, x10 ... ) so that fg only get new packet each frame, send multiplay each frame too, and see what happens.
not sure what is sent in the mp protocol from the netfdm, but if planes are smooth as mp plane, use a third fg session to visualise the 2 other (that need the use of a local mpserver)

addressing the problem in FG need some work in fg code to change the way netfdm work and probably the mp protocol behaviour when using external fdm. sadly the hackathlon is over :)

an other solution would be simulink able to send directly the mp protocol, so you just need one FG to see both planes as mp planes this would be interesting for more than 2 planes.
jano
 
Posts: 199
Joined: Thu Nov 29, 2007 11:32 pm
Location: france
Callsign: jano
Version: git
OS: debian SID

Re: Jitter when having two flight gear instances on local ma

Postby ma15rysi » Wed Dec 16, 2020 6:50 pm

So, in the last few days I tried to play around with the frequencies of the incoming and outgoing data. Both from Simulink and also for the local FGMP server. Together with a friend, we also tried that both of us started the Simulink simulation simultanously but each of us with only one FG instance connected to the same official FGMP server and we had the jitter as well. So it seems to be a problem with the native-fdm.
Gijs did you manage to replicate the problem?
ma15rysi
 
Posts: 10
Joined: Fri Dec 11, 2020 5:22 pm

Re: Jitter when having two flight gear instances on local ma

Postby Gijs » Sat Dec 19, 2020 12:13 pm

Hi,
ma15rysi wrote in Wed Dec 16, 2020 6:50 pm:Gijs did you manage to replicate the problem?

Sorry for the delay, but the answer is yes :-(

I did however manage to get a somewhat smooth operation by limiting the frame rate in FlightGear to 15 Hz with Simulink and multiplayer sending data at 30 Hz. But even that has some occasional jitter. See the following configs:
  1. FlightGear 1:
    Code: Select all
    fgfs --fdm=null --native-fdm=socket,in,30,localhost,5502,udp --native-ctrls=socket,out,30,localhost,5505,udp --multiplay=out,30,127.0.0.1,5000 --multiplay=in,30,127.0.0.1,5001 --callsign=Test1 --prop:/sim/frame-rate-throttle-hz=15
  2. FlightGear 2:
    Code: Select all
    fgfs --fdm=null --native-fdm=socket,in,30,localhost,5503,udp --native-ctrls=socket,out,30,localhost,5505,udp --multiplay=out,30,127.0.0.1,5001 --multiplay=in,30,127.0.0.1,5000 --callsign=Test2 --prop:/sim/frame-rate-throttle-hz=15
This pretty much confirms Jano's description.

What exactly is it that you're trying to do? If you do not need to be able to control the aircraft from FlightGear (i.e. all your data is going from Simulink -> FlightGear and not from FlightGear -> Simulink), it'd be easiest to just output the positions of the two aircraft to a single FlightGear instance and visualise them as AI planes, rather than actual aircraft. You won't even need to do anything with the multiplayer protocol then.

Gijs
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9361
Joined: Tue Jul 03, 2007 2:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Jitter when having two flight gear instances on local ma

Postby ma15rysi » Sat Dec 19, 2020 12:58 pm

Gijs wrote in Sat Dec 19, 2020 12:13 pm:
I did however manage to get a somewhat smooth operation by limiting the frame rate in FlightGear to 15 Hz with Simulink and multiplayer sending data at 30 Hz. But even that has some occasional jitter. See the following configs:
  1. FlightGear 1:
    Code: Select all
    fgfs --fdm=null --native-fdm=socket,in,30,localhost,5502,udp --native-ctrls=socket,out,30,localhost,5505,udp --multiplay=out,30,127.0.0.1,5000 --multiplay=in,30,127.0.0.1,5001 --callsign=Test1 --prop:/sim/frame-rate-throttle-hz=15
  2. FlightGear 2:
    Code: Select all
    fgfs --fdm=null --native-fdm=socket,in,30,localhost,5503,udp --native-ctrls=socket,out,30,localhost,5505,udp --multiplay=out,30,127.0.0.1,5001 --multiplay=in,30,127.0.0.1,5000 --callsign=Test2 --prop:/sim/frame-rate-throttle-hz=15

Ok, so I see you got the same jittery output. But it runs at least a litter smoother in this configuration than before, thanks for that. However, the problem is not only the jittery and jumpy behavior but also the delay in the position of the planes. For instance, in my test simulation, I try to simulate two planes exactly above each other but the flickering plane is always a little bit behind which makes the visaulization unusable for me.

But I think that your second point might help me out. The purpose is to control two planes and simulate In-Air Refueling for civil passenger planes. FG is only to have a proper and realistic visualization of the Simulink simulation. I know that FG already has the IAR feature implemented but first, I have to do a research project, hence military applications such as implemented in FG are not allowed to be used and second I want to control the complete plane behavior. But I didn't know about the AI planes yet. Maybe this is the better way to go in order to only visualize the planes. So yes, it is only data from Simulink going to FG and not the other way around.
ma15rysi
 
Posts: 10
Joined: Fri Dec 11, 2020 5:22 pm

Re: Jitter when having two flight gear instances on local ma

Postby jano » Sat Dec 19, 2020 5:23 pm

IF it's just for visual display of multiples planes without sending back environment props from FG, yes having fg mprotocol from simulink would do the job .


the recent mp code allow very good time synch between mp pilots, see the wiki page about this.

apart from the "real time" mode, you can use the multiplayer-> lag compensation menu and play with the lag adjustement slider, wich change the lag compensation added to mp planes. (master switch and apply to close mp need to be checked) (this will work only if the mp planes clocks are more than 400ms apart iirc, under the real time mode is active, so if needed, add an offset in "clock offset" for one fg instance and you then be able to have a working lag adjustement slider.


the other solution is to change a bit the net protocol , instead of sending unsigned integer unix time, wich is not used anywhere in FG, make simulink give timestamps with good precision , like elapsed seconds from last hour (utc time) as double, this would allow a bit of interpolation done for the net fdm ,allowing asynchronous run. but this need a bit of work :)

if you got question about lag compensation, feel free to ask :)

the key here is to not loose the time sync you have in simulink, and keep it it up to the mp planes.
jano
 
Posts: 199
Joined: Thu Nov 29, 2007 11:32 pm
Location: france
Callsign: jano
Version: git
OS: debian SID

Re: Jitter when having two flight gear instances on local ma

Postby ma15rysi » Sat Dec 19, 2020 7:34 pm

jano wrote in Sat Dec 19, 2020 5:23 pm:IF it's just for visual display of multiples planes without sending back environment props from FG, yes having fg mprotocol from simulink would do the job .

That question might seem to be a bit dumb but how can I access and manipulate the mprotocol? Because it is actually just the way you described it - to visualize without sending back any information.
ma15rysi
 
Posts: 10
Joined: Fri Dec 11, 2020 5:22 pm

Re: Jitter when having two flight gear instances on local ma

Postby jano » Sat Dec 19, 2020 9:41 pm

i really don't know how to do a new protocol in simulink (i don't have it and never used it) so can't be of big help for this :(
it's about making an udp packet identical to the ones used in mp protocol

did you try the slider to change lag compensation in the lag menu, to have planes more in synch ?
jano
 
Posts: 199
Joined: Thu Nov 29, 2007 11:32 pm
Location: france
Callsign: jano
Version: git
OS: debian SID

Re: Jitter when having two flight gear instances on local ma

Postby ma15rysi » Sun Dec 20, 2020 8:36 pm

jano wrote in Sat Dec 19, 2020 9:41 pm:did you try the slider to change lag compensation in the lag menu, to have planes more in synch ?

So, i tried the lag adjustment but it didn't really help...but perhaps I also used wrongly since I didn't really know how to set the adjustment...
ma15rysi
 
Posts: 10
Joined: Fri Dec 11, 2020 5:22 pm

Re: Jitter when having two flight gear instances on local ma

Postby ma15rysi » Sun Dec 20, 2020 8:42 pm

But I also tried sth else: I connected two planes with the following commands to a public server
Plane 1: --fdm=null --native-fdm=socket,in,30,localhost,5502,udp --native-ctrls=socket,out,30,localhost,5505,udp --multiplay=out,10,mpserver01.flightgear.org,5000 --multiplay=in,30,,5000 --callsign=Test1
Plane 2: --fdm=null --native-fdm=socket,in,30,localhost,5503,udp --native-ctrls=socket,out,30,localhost,5505,udp --multiplay=out,10,mpserver01.flightgear.org,5000 --multiplay=in,30,,5001 --callsign=Test2
Then I asked a friend to also connect to the same server. We flew at the same time and I passed him and we could see that it was still jittery. Subsequently, we did the same again but this time we placed his plane to a fix position in the air and he didn't move and this time we could see a completely smooth visualization of my overtaking planes. So maybe it also has something to do with the view or the movement of the camera.
ma15rysi
 
Posts: 10
Joined: Fri Dec 11, 2020 5:22 pm

Re: Jitter when having two flight gear instances on local ma

Postby jano » Sun Dec 20, 2020 11:00 pm

No it's not from the camera, it's only because lack of time synch is apparent when you got speed, if the 2 planes simulink driven are smooth when seen from an other fg session, you can use pilot list (menu multiplayer) and make the view attached to one of the mp plane, and see if they keep a good synch this way.

if you try to create a mp protocol udp packet with an udp block in simulink, the only really needed props to transmit are the position, orientation, and a timestamp witch should be the same for the 2 planes each frame. the velocity is only needed if you need to predict the plane's position in the futur, but there's a way to avoid it.
jano
 
Posts: 199
Joined: Thu Nov 29, 2007 11:32 pm
Location: france
Callsign: jano
Version: git
OS: debian SID

Next

Return to Multiplayer

Who is online

Users browsing this forum: No registered users and 1 guest