Board index FlightGear Development AI Traffic

Populate AI Traffic with real traffic

Intelligent, computer controlled vehicles that drive/fly over the planet!

Re: Populate AI Traffic with real traffic

Postby Thorsten » Mon Oct 29, 2012 3:42 pm

This is one of those cases where it would really make make sense to do all the position computations at the client side and merely provide "correction packets" to adjust the local/client-side extrapolation in fgfs, otherwise we'll be creating crazy amount of traffic unfortunately.


You really don't want to transmit position at all, you want to transmit derivative information. The correction would directly refer to the various velocities, i.e.:

* speed up to 280 kt, change vertical speed to 2000 fpm and turn with a rate of 30 deg/minute

would completely specify what the AI system has to do to get to the next known position, even if that position is a minute away (just instead of position interpolation, you calculate the velocities which will get you there). Basically, all you need is a single packet per minute for each plane if the AI system handles the actual motions client-side.

This is going to remain an issue anyhow: Whenever "real" data comes in, the "projected" (computed) flight path will need to be updated, even though it has already been used for up to 60 seconds by then. So aircraft will definitely "teleport" for the time being ...


No, it's not an issue if you accept a 1 minute lag, because then you know the future.

It's a simple progression:

* with one point (no lag) you can create a staircase curve 'close' to the real one which is discontinuous
* with two points (60 seconds lag) you can compute a derivative and make a continuous interpolation with discontinuous 1st derivatives
* with three points (120 seconds lag) you can compute a 2nd derivative and make the 1st derivatives continuous (I assume we don't really want that, as it then requires to also transmit accelerations as part of the MP packet)
Thorsten
 
Posts: 11611
Joined: Mon Nov 02, 2009 8:33 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Mon Oct 29, 2012 4:24 pm

Thorsten wrote in Mon Oct 29, 2012 3:42 pm:
This is one of those cases where it would really make make sense to do all the position computations at the client side and merely provide "correction packets" to adjust the local/client-side extrapolation in fgfs, otherwise we'll be creating crazy amount of traffic unfortunately.


You really don't want to transmit position at all, you want to transmit derivative information.

Yes, that was exactly the idea - IF we are able to move all the required computations to the client-side.

The correction would directly refer to the various velocities, i.e.:

* speed up to 280 kt, change vertical speed to 2000 fpm and turn with a rate of 30 deg/minute

would completely specify what the AI system has to do to get to the next known position, even if that position is a minute away (just instead of position interpolation, you calculate the velocities which will get you there). Basically, all you need is a single packet per minute for each plane if the AI system handles the actual motions client-side.


Yes, but at the moment the fgms/fgfs MP system simply isn't there yet. However, it would surely be a good idea to think about what's needed to make that happen, because it would also improve the conventional MP system quite a bit at the same time.


No, it's not an issue if you accept a 1 minute lag, because then you know the future.

Yes, which is why I earlier suggested that we should use this approach, but there were different opinions voiced regarding lagging, i.e. interpolation vs. extrapolation.

I'm getting the feeling that many of these problems must have already been solved as part of HLA, so before we really re-invent the wheel here,it would surely be a good idea to look at what's provided there already.

Finally, there are certain things that can be accomplished now (which we are working on already), while others would require modifications of fgms and also fgfs - keeping in mind that the MP system hasn't been actively maintained in quite a while ... so, we need to focus on what's possible right now
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Mon Oct 29, 2012 7:35 pm

You really don't want to transmit position at all, you want to transmit derivative information. The correction would directly refer to the various velocities, i.e.:

* speed up to 280 kt, change vertical speed to 2000 fpm and turn with a rate of 30 deg/minute

would completely specify what the AI system has to do to get to the next known position, even if that position is a minute away (just instead of position interpolation, you calculate the velocities which will get you there). Basically, all you need is a single packet per minute for each plane if the AI system handles the actual motions client-side.


This solution should be really great but need a lot of modification in the flightgear source code and I'm not sure to be able to do that.
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Mon Oct 29, 2012 7:45 pm

Yes, we can look into that once FGAIS as such works properly. We are probably only 2-3 steps away from a working fgms-based prototype now. Which means probably 2-3 weeks of "spare time" coding (weekends).

But like I said, I agree it would be really good (not just for FGAIS) but FGMS/FGFS MP not being actively developed/maintained, I'm not too optimistic actually ... And many of these problems are almost certainly already solved in HLA, which we should check prior to coding anything related to this.

Personally, I find the fgms code base and its "design" a bit challenging to work with, given that, but also the HLA trend, I am currently not too interested in taking over maintenance ...
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Mon Oct 29, 2012 10:30 pm

First AI traffic received from FGMS !!!

Image

Now, I need to solve the dozens of errors :D But at least : IT WORKS !
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Mon Oct 29, 2012 10:32 pm

hey, you have made lots of progress again!
What errors do you mean? build/compile errors or runtime errors?
You can also push the current version to a branch so that I can have a look and see if I can help fixing some things.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Mon Oct 29, 2012 10:39 pm

It's pushed ;)

Be careful : the recompute() function took 25 secondes ! (calculate 60 positions for ~10k aircrafts is the price to pay...)
No problem of compilation for FGMS, no problem of running, just some value not correct in the MP packet. I need to investigate it tomorrow.

However FG client throws a lot of error and "BAD MP PACKET" appears, also a lot of Nasal message appears because a lot of properties doesn't exist. I think that I need to create some fictive properties.
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Mon Oct 29, 2012 11:49 pm

On average, just 1/50 of the total number of aircraft are relevant for each fgfs client.
With the current implementation, we'd be down to 30 seconds/50 = 0.6 seconds per client for ~200 aircraft.
Using a spatial data structure like a quadtree or geohash instead of just std::map will also reduce the runtime footprint significantly.
Pre-building message packets for different time offsets is "embarrasingly parallel", i.e. can be trivially run in worker threads (i.e. a thread pool) if necessary.

Like I said, I suggest to focus in fixing all bugs first, and then making sure that expired aircraft are added to a "deadlist" so that they can be properly deleted.
Afterwards, we can look into optimizing the whole thing a little more.

Also, some of the SG helpers that are used, could use memoization (caching) to improve the runtime footprint further.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

without words

Postby Hooray » Wed Oct 31, 2012 10:13 pm

Image

Look at my frame spacing: from 25 ms up to 120 ... due to 90+ MP aircraft at KSFO :shock:
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Wed Oct 31, 2012 10:19 pm

Fantastic !!! FGAIS become reality :)
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

note that this requires ZERO changes in FlightGear!!!

Postby Hooray » Wed Oct 31, 2012 11:48 pm

Image

Image
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: note that this requires ZERO changes in FlightGear!!!

Postby Philosopher » Thu Nov 01, 2012 1:30 am

Wow! Great news! Nice work, both of you, give yourself a pat on the back!
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Thu Nov 01, 2012 12:27 pm

This morning at LFML with real life AI traffic :

Image
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Thu Nov 01, 2012 4:33 pm

Well, FlightGear has some real issues with lots of multiplayer traffic.

On the one hand, the existing MP protocol and implementation in fgfs/fgms are obviously not very efficient and create tons of unnecessarytraffic. So we will inevitably need to provide less traffic than there really is for now. Otherwise, it's possible to saturate a 100 MBIT uplink with just a few clients unfortunately.

On the other hand, the frame rate and frame spacing suffer heavily when FG shows so many MP aircraft. At KSFO, there are usually 200+ aircraft within 100 nm. That's something that FG simply cannot deal with currently. So we may need to configure a limit that people can customize until FG is optimized to perform better.

The other thing is GUI related: the MP list dialog causes tons of "Too many live PUI interface" messages in the console, and then the GUI dialog crashes or fgfs even segfaults due to the sheer number of pilots. This doesn't happen with "just" 30-50 aircraft shown though.

Like I mentioned earlier, I feel that it would be a good option to consider the OpenRTI/HLA route eventually, because that will make it much easier to provide an efficient implementation that doesn't just send positional data, but instead derivative motion information at much greater intervals, i.e. lower update rates. That would allow us to "inject" 200+ aircraft into FG and only update them once or twice per minute.

However, I feel that this is something that should be considered after 3.0 or even 3.2
For now, I'm happy to continue using fgms to improve the implementation.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby Johan G » Thu Nov 01, 2012 4:51 pm

Maybe time to make the pilot list scrollable? :wink:

Looks nice otherwise. Lots of aircraft to intercept. :wink:
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5722
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

PreviousNext

Return to AI Traffic

Who is online

Users browsing this forum: No registered users and 0 guests