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 wlbragg » Sat Oct 13, 2012 1:46 pm

How do you handle departures and arrivals, especially departures?
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
User avatar
wlbragg
 
Posts: 3729
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Debain/nVGT640

Re: Populate AI Traffic with real traffic

Postby stuart » Sat Oct 13, 2012 2:32 pm

I agree that the fgais <-> fgms <-> FG achitecture makes sense.

I had a look at the fgais and fgms code last night. Combining them into an fgais server that's MP aware and only sends data for aircraft in the area of MP aircraft looks pretty straightforward.

I'm happy to do that but I'm a bit short of dedicated coding time right now so it may take me some time. Clement - what are your plans?

-Stuart
G-MWLX
User avatar
stuart
Moderator
 
Posts: 1333
Joined: Wed Nov 29, 2006 9:56 am
Location: Edinburgh
Callsign: G-MWLX

Re: Populate AI Traffic with real traffic

Postby Hooray » Sat Oct 13, 2012 5:15 pm

been in touch with F-JJTH and Stuart regarding the fgms-based design, to make sure that we don't follow a path that's a dead end ...
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: 10677
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Sun Oct 14, 2012 12:38 pm

Hi all,

After PM discussion with Hooray I created a new gitorious project : https://gitorious.org/fgais
Hooray started a wiki page available here : http://wiki.flightgear.org/FGAIS

I have forked fgms and already done some change without action, before coding we need a brainstorming in order to avoid to spend our time re-doing things because we started in wrong way. You can see it here :

- https://gitorious.org/fgais/fgais/blobs ... x#line1417
- https://gitorious.org/fgais/fgais/blobs ... fg_ais.cxx

Clement - what are your plans?
Let me know if the todolist in fg_ais.cxx is a good start.
In a first time we can keep the POS_DATA_ID Message identifiers in order to receive AI traffic as MP traffic. In second time we will see at flightgear side how to route MP traffic to AI manager with filter.

I will start by implementing the "aiurl" config parser and insert some function I had already create in my original FGAIS project (receiveDataFromJson(), Split(), aircraftToPath(), parseJson(), ...)

Hooray and stuart, let me know which part of the todolist are you able to be interest to investigate.

Cheers,
Clément
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Sun Oct 14, 2012 1:55 pm

I agree that we need a brainstorming, it's obvious that we already disagree regarding some implementation details - so we better find a consensus before coding.
Regarding https://gitorious.org/fgais/fgais/blobs ... cxx#line32 just briefly:

  • fgms already knows the current position of the client and also uses it for the same purpose
  • fgms also already has support for excluding traffic beyond a certain range and extrapolating positional info
  • actually, we can (and should) use the POS_DATA_ID message type, then we would not need to modify the existing code: https://gitorious.org/fgais/fgais/blobs ... ssages.hxx
  • we could simply change the header so that fgfs/fgms know that this is a special type of relay server, that could either be configured in addition to other MP servers at the client-side, or as a relay at the server-side (what do you prefer?)
  • in the beginning, I would suggest to keep it simple and just use the existing MP protocol
  • SimGear already has a HTTPRequest class for making HTTP request - that should be used as the backbone of the "Provider" interface
  • Basically: HTTPRequest -> JSONRequest -> JSONResponseParser -> AITrafficProvider (along these lines, each being a sub class derived from the previous class)
  • regarding the scheduling of asynchronous events for processing JSON requests at 20 second intervals, and for extrapolating the position in the meantime, we could use a separate thread that runs a simple scheduler in the background - FG and SimGear already have code for this sort of thing (see SGTimer).

Personally, I feel we shouldn't touch any of the existing features in fgms: that would make it unnecessarily complicated to merge changes back upstream. Instead, we should add new "mode" to fgms, to use other traffic sources and inject data from web feeds (JSON). By not touching any of the other fgms features, we can also more easily re-use existing code, but also simply use the "RELAY" feature supported by fgms, to connect "FGAIS" as a relay to our MP network.
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: 10677
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Sun Oct 14, 2012 6:15 pm

Hooray wrote in Sun Oct 14, 2012 1:55 pm:[*] fgms also already has support for excluding traffic beyond a certain range

Yes but he can only compare distance between 2 clients. FGAIS is not a client else he will appears as MP traffic and not as AI traffic. So we can't re-use this function.

Hooray wrote in Sun Oct 14, 2012 1:55 pm:[*] we could simply change the header so that fgfs/fgms know that this is a special type of relay server, that could either be configured in addition to other MP servers at the client-side, or as a relay at the server-side (what do you prefer?)

I think that we should add the feature "as part of fgms". For example if we implement fgais into fgms then mpserver13.flightgear.org install this new fgms : only user connected to mpserver13.flightgear.org could be enable AI traffic.
It's like FGTracker : only some mpserver are able to give stat with FGTracker. Here it's the same only updated fgms will be able to send AI traffic.

Maybe a little draft of "how I see" is better :

Image

As you can see only client connected to the FGMS+FGAIS can receive AI traffic (of course they continue to receive other client data like it's done since a lot of years)
Relay datas contain only data of FGFS clients, not AI traffic. (also like it's done since a lot of years)

What do you think about this technique ?

Hooray wrote in Sun Oct 14, 2012 1:55 pm:[*] regarding the scheduling of asynchronous events for processing JSON requests at 20 second intervals, and for extrapolating the position in the meantime, we could use a separate thread that runs a simple scheduler in the background - FG and SimGear already have code for this sort of thing (see SGTimer).

I would prefer to keep independant of SimGear. I prefer to do that in "pure" C++, not across external library like SimGear.

Hooray wrote in Sun Oct 14, 2012 1:55 pm:Personally, I feel we shouldn't touch any of the existing features in fgms: that would make it unnecessarily complicated to merge changes back upstream. Instead, we should add new "mode" to fgms, to use other traffic sources and inject data from web feeds (JSON).

Totally agreed with you.

I commited a script who compile FGMS+FGAIS on gitorious repo. Also I have implemented a simple "Hello World!" (in fact it's "FGAIS is here") : now we now that the loop is executed every seconds :) maybe a simple counter between 0 and 20 should be sufficient for the scheduler. I mean something like :
Code: Select all
if(elapsedTime = 20){
  updateJsonDataFromProvider();
  elapsedTime = 0;
  computeRealAIPositionFromFreshJsonData();
  dataToBeSent = createNetworkPacketFromComputedAIPosition();
  sendOverNetwork(dataToBeSent);
}elseif(elapsedTime = 4 OR elapsedTime = 8 OR elapsedTime = 12 OR elapsedTime = 16){
  computeFictiveAIPositionFromPreviousAIPosition();
  dataToBeSent = createPacketForNetwork();
  sendOverNetwork(dataToBeSent);
}else{
  nothing to do, we already update "fictive" position every 4 seconds and update "real" position every 20 seconds with "fresh" JsonData from our provider.
}


What do you think about that ? Of course it's a simplification of the process, I always start by representing simple mechanisms in order to keep a clear view of the project.

Stuart & Hooray: you have commiter right on fgais repo ;)

Hooray: you are right, I'm not familiar with C++ but my goal here is also to learn C++ :) I hope to have a good C++ experience with this project. But your argument is totally correct : if Nasal is implemented we can hope to interest more contributor. Are you able to implement it in the fgais repo and write a little demo ?

Cheers,
Clément

Cheers,
Clément
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Sun Oct 14, 2012 6:31 pm

Just briefly: Regarding the use of Nasal, I actually agree with your earlier point that it isn't stricly needed (at all) - however, certain things will inevitably require modifications and custom code, either in the form of 3rd party dependencies (libraries) or custom scripts. As far as I can tell, your C++ knowledge seems absolutely sufficient so far. You have progressed much farther than anybody else who's worked on related ideas, so I really wouldn't worry about using C++.

Personally, I don't see anything wrong with using SimGear, because it's already used by fgms, but currently the required headers/code files are copied to the fgms source tree instead.

Now, as to Nasal, yes - I would volunteer to add a proof of concept, and implement it in fgms - however, I don't want to enforce it at all - Thus, I have sent a message to the fgms developer asking for his opinion on the whole idea, given that we probably don't want to maintain a fork - but just a "topic branch", so that our changes can be merged back eventually.
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: 10677
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby wlbragg » Sun Oct 14, 2012 9:55 pm

How are you all planning on handling the existing AI traffic file schedules and again the takeoffs and landing?
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
User avatar
wlbragg
 
Posts: 3729
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Debain/nVGT640

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Mon Oct 15, 2012 9:03 am

Hi wlbragg,

It seems that we don't speak about the same things. You are asking how handle AI traffic in FlightGear, but here we are speaking about how to implement a new add-on on FGMS in order to send special traffic over MP.

Cheers,
Clément
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 15, 2012 10:42 am

yes, in other words, this will be a completely different system (data source) to inject real world traffic into the FlightGear Multiplayer/AI environment - without even being necessarily aware of these other two systems, so it isn't unlikely that - at least in the beginning- you'll want to disable those, for a plausible experience. Otherwise, it's worth keeping in mind that traffic won't be aware of other traffic sources, and definitely won't take evasive maneuvers.
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: 10677
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Mon Oct 15, 2012 1:10 pm

I would prefer to keep independant of SimGear. I prefer to do that in "pure" C++, not across external library like SimGear.

Just to clarify (and I'm sure Stuart will agree here): C++ is generally considered a "bare bones" language, i.e. "without batteries included", i.e. unlike Java or Python, you really have just a language without any useful features.

So it is only natural that libraries must be used to accomplish a certain task. There are some "standard" libraries, like the Standard Template Library (STL), and increasingly, Boost or Poco.
But generally, you'll really want to use existing libraries to make your life easier. People who don't do that need to "re-invent the wheel" more often than not, and write even the most basic things from scratch, which is time-consuming and very tedious.

That being said, SimGear really has very useful helpers available, not just the SGTimer class, but also the HTTPRequest class: https://gitorious.org/fg/simgear/blobs/ ... equest.cxx
For some other HTTP helpers, please see: https://gitorious.org/fg/simgear/trees/next/simgear/io
These are used to implement the METAR subsystem, which is also a simpler "HTTP/WEB SCRAPER".

So, I am really convinced that we want to use SimGear here - especially, because SimGear already solves all of these problems in a multi-platform fashion. If you don't want to add SimGear as a a dependency, you could follow the fgms technique, and simply copy all required sources to the fgais source tree, so that fgais itself is fairly self-contained doesn't have additional external dependencies.

After taking a look at the HTTPRequest class, you'll probably agree that it should be fairly straightforward to build a little JSON-Parser on top of it.
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: 10677
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Mon Oct 15, 2012 3:07 pm

I try to include my FGAIS work into fgms without success since 7 hours.
I think that my C++ skill are now achieved and I can't continue this project.
I have no idea how to include SimGear, no idea how to use an external library, no idea how to share variables across multiple files. The OOP is totally unknow for me (fgms is writer in OOP)

If someone with enough skill is interested to continue my work I can release source code under GPLv2.
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 15, 2012 3:17 pm

Hi, sorry to hear that you are facing some issues - but none of these are really critical, and we can help with all open questions, including C++ help. :D
That said, actually that would seem to suggest that it would really be a worthwhile idea to pursue the Nasal route and add scripting faciliites to fgms?

Now, regarding your questions:

To share variables across multiple files, you can simply use "global" variables - and declaring them "extern" in your sources.
OOP in C++ is probably more easily explained after you have understood how C structs work, or how Nasal hashes work.
The simplest option to use existing source code, is to simply copy it into your project - i.e. HTTPRequest.cxx and HTTPRequest.hxx and by adding it to the build system
To use another previously installed library in C++, you would need to include its header files and link in the library - which is usually done via the build system, see CMakeList.txt: http://wiki.flightgear.org/Developing_using_CMake

I am sure that we can sort out all issues, so please don't worry ;-)
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: 10677
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby wlbragg » Mon Oct 15, 2012 4:05 pm

Common guys, give me a break. I know exactly what your doing. We do talk the same language. I've been a programmer for 30 years! I guess some of us maybe don't listen so well. :? Then again, two of you misunderstood my question. So maybe it is my question that needs clarification.

Your going to have a new system injecting traffic into FlightGear based on real time data from a json feed, I get that, has anyone considered how you are going to handle arrivals and departures of these aircraft.
I've been to these flight trackers. You normally go to track a specific flight that you know has already been scheduled. Your looking at it from a different point of view. You expect it to just popup on the screen when it gets airborne. What, are you going to just have a plane pop up out of know where when the flight starts and just as quickly disappear at its destination when it finishes? Because that is what the data your using is going to do. No- taxiing, no touchdowns. Maybe that is OK, I don't know! I just was raising the question because no one else has.

But you did answer one question about it and that it is NOT going to effect any existing system. Other than maybe a lot of near misses! :lol: Good deal, I think that is a wise choice for now.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
User avatar
wlbragg
 
Posts: 3729
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Debain/nVGT640

Re: Populate AI Traffic with real traffic

Postby Hooray » Mon Oct 15, 2012 4:10 pm

wlbragg wrote in Mon Oct 15, 2012 4:05 pm:I've been a programmer for 30 years!


With that sort of background, you'll surely understand that we need to walk before we run, right? :D
Seriously though, as you have probably read, F-JJTH is currently facing some C++ related issues - so if you have anything to contribute to the issues HE mentioned, your feedback/help would surely be appreciated ;-)
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: 10677
Joined: Tue Mar 25, 2008 8:40 am

PreviousNext

Return to AI Traffic

Who is online

Users browsing this forum: No registered users and 1 guest