Board index FlightGear Development AI Traffic

Populate AI Traffic with real traffic

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

Populate AI Traffic with real traffic

Postby F-JJTH » Mon Oct 01, 2012 7:49 pm

Hi all,

I think a lot of you know this kind of website who display aircraft from real world in real time. Some example :
- http://www.flightradar24.com/
- http://planefinder.net/
- http://www.radarvirtuel.com/

There is the same for ship :
- http://shipfinder.co/
- http://www.marinetraffic.com/ais/

My dream is simple : populate FG world with data from these kind of website.
Imagine : you are in your home and an aircraft is in the sky, you run at your computer and start FG then you can fly around the aircraft that you have just see in real life.

I think this feature can bring a lot of realism for FG. For example you are at EDDF and in real life there is a 777 landing, in FG the same thing appear. In other words : AI traffic in FG is in fact real traffic in the world in real time.

Now the idea is presented, I can speak a little bit about the technical problem :

1) we need to receive the data from a website who provide aircraft position : this task is really easy and I have already modified FG source code for this
2) we need to adapt aircraft data received for FG multiplayer format. Data received from website are JSON format, so we need to parse JSON data in order to exctract position, model, heading, airspeed...
3) once we have to create a network packet filled by exctracted datas and send it every 20 seconds on the Multiplayer network.
This work should be done by a special server/tool.

I have already make some experimentation : i am able to create AI aircraft in local session with data from planefinder.net. In this way I have a dozens of aircraft in my /ai/models/aircraft[n] with data refreshed every 20 seconds. Undortunately this solution doesn't create a real AI aircraft but create only a simple Node in the property tree.

The nasal code for this is :
$FG_DATA/Nasal/real_traffic.nas
Code: Select all
#########################################################################
# Real time traffic manager. Add aircraft and ship in the world
# with data from planefinder.net
#
#
#
#
#########################################################################

props.globals.initNode("/sim/traffic-manager/real-traffic", 0, "BOOL");
props.globals.initNode("/sim/traffic-manager/aircraft-data", "", "STRING");



var aircraftLoop = func {

  if(getprop("/sim/traffic-manager/real-traffic")){

  var aircraftUrl = "PUT_YOUR_URL_HERE";
  fgcommand("jsonhttprequest", props.Node.new({"url":aircraftUrl, "targetnode":"/sim/traffic-manager/aircraft-data"}) );
  var jsonSource = getprop("/sim/traffic-manager/aircraft-data");
  var jsonSplittedA = split("{", jsonSource);
  var jsonSplittedB = split("}", jsonSplittedA[2]);
  var jsonSplittedC = split("],", jsonSplittedB[0]);
  var aircraftData = {};
  var _hexcode = "";
  var _type = "";
  var _callsign = "";
  var _latitude = "";
  var _longitude = "";
  var _altitude = "";
  var _heading = "";
  var _airspeed = "";


  for(var i=0; i < size(jsonSplittedC); i=i+1){

    var jsonSplittedD = split(":[", jsonSplittedC[i]);
    var jsonSplittedE = split("]", jsonSplittedD[1]);
        jsonSplittedD[1] = jsonSplittedE[0];
    var jsonSplittedH = split('"', jsonSplittedD[0]);
        _hexcode = jsonSplittedH[1];
    var jsonSplittedF = split(",", jsonSplittedD[1]);

    for(var z=0; z < size(jsonSplittedF); z=z+1){

      var jsonSplittedG = split('"', jsonSplittedF[z]);
      if(size(jsonSplittedG) > 1){
        if(z == 0){
          _type = jsonSplittedG[1];
        }elsif(z == 1){
          _callsign = jsonSplittedG[1];
        }
      }else{
        if(z == 3){
          _latitude =jsonSplittedG[0];
        }elsif(z == 4){
          _longitude = jsonSplittedG[0];
        }elsif(z == 5){
          _altitude =jsonSplittedG[0];
        }elsif(z == 6){
          _heading = jsonSplittedG[0];
        }elsif(z == 7){
          _airspeed = jsonSplittedG[0];
        }
      }
    }
    aircraftData[i] = {
                       hexcode:_hexcode,
                       type:_type,
                       callsign:_callsign,
                       latitude:_latitude,
                       longitude:_longitude,
                       altitude:_altitude,
                       heading:_heading,
                       airspeed:_airspeed
                      };
  }

  for(var y=0; y < size(aircraftData); y=y+1){

    print("##### Aircraft "~y);
    print("HexCode: "~aircraftData[y].hexcode);
    print("Callsign: "~aircraftData[y].callsign);
    print("Latitude: "~aircraftData[y].latitude);
    print("Longitude: "~aircraftData[y].longitude);
    print("Altitude: "~aircraftData[y].altitude);
    print("Heading: "~aircraftData[y].heading);
    print("Airspeed: "~aircraftData[y].airspeed);
    print();

    var aiPath = "/ai/models/aircraft";

    props.globals.getNode(aiPath~"["~y~"]"~"/hexcode", 1).setValue(aircraftData[y].hexcode);
    props.globals.getNode(aiPath~"["~y~"]"~"/callsign", 1).setValue(aircraftData[y].callsign);
    props.globals.getNode(aiPath~"["~y~"]"~"/position/latitude-deg", 1).setValue(aircraftData[y].latitude);
    props.globals.getNode(aiPath~"["~y~"]"~"/position/longitude-deg", 1).setValue(aircraftData[y].longitude);
    props.globals.getNode(aiPath~"["~y~"]"~"/position/altitude-ft", 1).setValue(aircraftData[y].altitude);
    props.globals.getNode(aiPath~"["~y~"]"~"/orientation/true-heading-deg", 1).setValue(aircraftData[y].heading);
    props.globals.getNode(aiPath~"["~y~"]"~"/velocities/true-airspeed-kt", 1).setValue(aircraftData[y].airspeed);


  }

  }

  settimer(aircraftLoop, 20);

}

var nasalInit = setlistener("/sim/signals/fdm-initialized", func{
  # We sent 1 request at starting in order to fill the property
  var aircraftUrl = "http://planefinder.net/endpoints/update.php?faa=1&bounds=43.765091%2C-3.155133%2C48.010089%2C10.204242&_=1348996787623";
  fgcommand("jsonhttprequest", props.Node.new({"url":aircraftUrl, "targetnode":"/sim/traffic-manager/aircraft-data"}) );

  settimer(aircraftLoop, 2);
  removelistener(nasalInit);
});


The function added to flightgear is :
flightgear/src/Main/fg_commands.cxx
Code: Select all
class RemoteJSONRequest : public simgear::HTTP::Request
{
public:
    SGPropertyNode_ptr _complete;
    SGPropertyNode_ptr _status;
    SGPropertyNode_ptr _failed;
    SGPropertyNode_ptr _target;
    string propsData;
   
    RemoteJSONRequest(const std::string& url, SGPropertyNode* targetNode) :
        simgear::HTTP::Request(url),
        _target(targetNode)
    {
    }
   
    void setCompletionProp(SGPropertyNode_ptr p)
    {
        _complete = p;
    }
   
    void setStatusProp(SGPropertyNode_ptr p)
    {
        _status = p;
    }
   
    void setFailedProp(SGPropertyNode_ptr p)
    {
        _failed = p;
    }
protected:
    virtual void gotBodyData(const char* s, int n)
    {
        propsData += string(s, n);
    }
   
    virtual void responseComplete()
    {
        int response = responseCode();
        bool failed = false;
        if (response == 200) {
            try {
                const char* buffer = propsData.c_str();
                _target->setStringValue(buffer);
            } catch (const sg_exception &e) {
                SG_LOG(SG_IO, SG_WARN, "parsing JSON from remote, failed: " << e.getFormattedMessage());
                failed = true;
                response = 406; // 'not acceptable', anything better?
            }
        } else {
            failed = true;
        }
    // now the response data is output, signal Nasal / listeners
        if (_complete) _complete->setBoolValue(true);
        if (_status) _status->setIntValue(response);
        if (_failed) _failed->setBoolValue(failed);
    }
};


static bool
do_load_json_from_url(const SGPropertyNode * arg)
{
    std::string url(arg->getStringValue("url"));
    if (url.empty())
        return false;
       
    SGPropertyNode *targetnode;
    if (arg->hasValue("targetnode"))
        targetnode = fgGetNode(arg->getStringValue("targetnode"), true);
    else
        targetnode = const_cast<SGPropertyNode *>(arg)->getNode("data", true);
   
    RemoteJSONRequest* req = new RemoteJSONRequest(url, targetnode);
   
// connect up optional reporting properties
    if (arg->hasValue("complete"))
        req->setCompletionProp(fgGetNode(arg->getStringValue("complete"), true));
    if (arg->hasValue("failure"))
        req->setFailedProp(fgGetNode(arg->getStringValue("failure"), true));
    if (arg->hasValue("status"))
        req->setStatusProp(fgGetNode(arg->getStringValue("status"), true));
       
    FGHTTPClient::instance()->makeRequest(req);
   
    return true;
}


If you are able to compile FG with this change and add the real_time.nas file in $FG_DATA/Nasal you just need to set the /sim/traffic-manager/real-traffic property to True and you will see your /ai/models/ tree growing with aircraft[n] who represent aircraft position currently flying in real life.

Of course this technical solution is not the good solution. The good solution is to follow instructions available at the top of my post.

I have spent a lot of time reading flightgear/src/MultiPlayer/multiplayermgr.cxx I have also read the mpdummy tools and the fgms source code, but my skills in C++ are not sufficient for create a standalone tool who create network packets ready to be sent on FG network.

Now come the questions :

- What do you think about this feature ?
- Do you think that adding real traffic in real time inside flightgear is not an interesting feature ? or per contra you thing this feature should be really great for the realism ?
- Who is able to create this kind of tool ?

Cheers,
Clément
Last edited by F-JJTH on Sun Oct 07, 2012 8:29 pm, edited 1 time in total.
User avatar
F-JJTH
 
Posts: 696
Joined: Fri Sep 09, 2011 12:02 pm

Re: Populate AI Traffic with real traffic

Postby Hooray » Mon Oct 01, 2012 8:41 pm

There have been lots of talk on the devel list about using such "real traffic" feeds to inject traffic into the FG MP world: http://wiki.flightgear.org/Decoupling_t ... ultiplayer
And there have been talks on the devel list about decoupling the AI traffic system from FG so that it can be run in a separate process: http://wiki.flightgear.org/Decoupling_t ... stem#Goals

Overall, your code looks like an interesting proof of concept - but keep in mind that the current FG/MP scheme is pretty obsolete/inflexible, and hasn't been actively developed or maintained for years: http://wiki.flightgear.org/Distributed_ ... h_Priority

A while ago, Mathias mentioned that his HLA work is intended to make such scenarios simpler: http://wiki.flightgear.org/FlightGear_H ... chitecture)

In other words, it should be obvious that there are many people interested in this sort of thing (just take a look at the devel list archives) - you may want to turn this into a feature request and post it on the issue tracker: http://flightgear-bugs.googlecode.com/
The fact that you have some sample code should give your idea some momentum.
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Wed Oct 03, 2012 12:12 am

Thanks you for the answer Hooray.

Finally I have finished the parse of planefinder.net data. My next step is to make some clean in aircraft data (some aircraft from planefinder.net are without callsign for example).

After that I need help for the creation of the network packet. I have really no idea how to format network packet matching FG format.
Parsed data are :
Code: Select all
            ID:  CX96
      Aircraft:  B744
      Callsign:  z.NO-REG
      Latitude:  54.65
     Longitude:  176.7
      Altitude:  37000
       Heading:  56
      Airspeed:  510



My main problem for now is that FGMS considering the client as died after 10 seconds without receiving data from the client. Unfortunatly my tool take 1m30s to run.
I don't know if source code optimisation are able to run the tool in 10 seconds maximum...

Another solution is to predict the next position of the aircraft by computing current position/airspeed/heading and send this predicated network packet over network waiting the end of the next loop. I think this technical solution need threading and I don't know nothing about it.

For information I called this tool "fgais" for FlightGear AI Server.

Hoping that populate FG world interest more person than me :)

Cheers,
Clément
User avatar
F-JJTH
 
Posts: 696
Joined: Fri Sep 09, 2011 12:02 pm

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Sun Oct 07, 2012 8:42 pm

Ok, finally I have successfully create what I want, or at least the beginning of it.

Image

After some test the result is clear : FGAIS can't be used on MP because there is too many data. mpmap01.flightgear.org is completely out when I send data to fgms.
Now I need to investigate at flightgear in order to see if flightgear is able to handle 2 input connection at same time.

The final goal is simple : FGAIS could be include into flightgear package (like terrasync, fgjs, metar, fgelev...). Every users could enable/disable it at runtime (like terrasync). In this way every users can see the same AI aircraft at the same position (of course some lag will appears : nobody has the same internet connection)

A big works is to create a table of correspondance between aircraft model given by FGAIS and AI aircraft.

Cheers,
Clément
User avatar
F-JJTH
 
Posts: 696
Joined: Fri Sep 09, 2011 12:02 pm

Re: Populate AI Traffic with real traffic

Postby Johan G » Mon Oct 08, 2012 6:21 am

F-JJTH wrote in Sun Oct 07, 2012 8:42 pm:FGAIS can't be used on MP because there is too many data. mpmap01.flightgear.org is completely out when I send data to fgms.

Also consider that the added traffic will explode the bandwidth required by the multiplayer servers, possibly breaking bandwidth limitations:
Howto:Set up a multiplayer server#Traffic & Bandwidth Considerations:
In March 2008, the main fgms multiplayer server (pigeond.net) was reported to consume approximately 15 gb of bandwidth per day, with an average throughput of 200 kB/sec and peak loads of up to ~ 650 kB/sec.


F-JJTH wrote in Sun Oct 07, 2012 8:42 pm:A big works is to create a table of correspondance between aircraft model given by FGAIS and AI aircraft.

I guess this might help: ICAO DOC 8643 - Aircraft Type Designators, or more specifically this list: Part2 - By Type Designator (Decode) (PDF). If it works it can probably be reused in other places in FlightGear.
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)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Populate AI Traffic with real traffic

Postby stuart » Mon Oct 08, 2012 10:15 am

Hi Clément,

This is really great work! Can you share the code for FGAIS?

I had something similar to your JSON/Nasal client working a while ago for ship AIS, but didn't have the time to develop something more substantial.

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

Re: Populate AI Traffic with real traffic

Postby Hooray » Mon Oct 08, 2012 1:30 pm

That looks very promising!

The current MP system probably isn't able to deal with this amount of "traffic" at the client-side - thus, it might make more sense to develop this as a server-side module, that can be run as part of the fgms process.

See this thread for some fgms-related pointers: viewtopic.php?f=18&t=13510&hilit=#p136501

PS: I wouldn't name it FG "AIS", because AIS is about vessel tracking (ships), like Stuart mentions - which is another option obviously, because AIS feeds are also available and could be used in FG to populate our scenery with ships (Basically, AIS is analogous to TCAS/ADS-B, i.e. a VHF-based transponder system that sends out GPS-data (and extrapolated data like CoG, RoT etc) over VHF)

Image

Regarding the work that Stuart mentioned, you may want to take a look at these discussions:

EDIT: Thinking about it, the best option would probably be forking fgms and implementing this as part of a custom fgms fork - that way, it could be either configured as a relay by existing servers, or simply used as an additional MP server at the client-side, so that the MP system in FG would only need to support multiple concurrent fgms connections to different servers. That way, we wouldn't be overloading the main fgms network, but just have an additional network of fgms servers that use real traffic feeds
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Mon Oct 08, 2012 9:40 pm

Hi all,

@Johan G: your PDF file seem to be exactly what I need ! thanks you !

@stuart: I'm not ready to release the source code, to be honest this tool can be used to create a DoS attack. If this tool is used by someone with bad intention I can't imagine what could happen on fg network...

@stuart & @Hooray: I have already planned to provide ship position. In fact it's already doable :) but not yet tested on MP

I will be busy for the next of the week I think I will be able to continue my work next week.

Cheers,
Clément
User avatar
F-JJTH
 
Posts: 696
Joined: Fri Sep 09, 2011 12:02 pm

Re: Populate AI Traffic with real traffic

Postby Hooray » Mon Oct 08, 2012 10:43 pm

Like I said earlier, it would make sense to start moving the implementation to the fgms side of things - and away from the client.
That would allow us to have a single fgms instance, just for aircraft/vessel traffic - without doing all the parsing at the client side.
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Thu Oct 11, 2012 6:08 pm

Hi all,

Here is the current source code : http://clemaez.fr/flightgear/fgais_src.tar.gz

@stuart: let me know if you are ready to participate at the development of this tools.

For the moment I have no idea what to do more... there is a lot of bug (it's normal... it's in development) but I think that my tool is not started as he should. I have a lot of questions without answer like :
- My tool is here to generate AI traffic but since he send packet in MP every aircraft are considered like MP traffic not like AI traffic. I prefer to see these aircraft as AI traffic (it means to include it into flightgear source)
- My tool send position of worldwide aircraft to every client but the client situated at Paris is not interested by the aircraft situated at New York. (it means to receive position of client and send only aircraft position within 100nm for example)
- My tool is not able to update position of aircraft. Each 6 seconds every aircrafts are deleted then re-sent like new aircraft. I can't compare previous position with current position for example. it's a big problem because acceleration/velocity calculation is impossible.
- My tool should send aircraft position of the previous position in order to keep a position in advance for interpolation calculation. Currently my tool parse aircraft position then send them over MP. But he should parse aircraft position, then parse a second time aircraft position in order to know if the aircraft is moving (heading change, climbing, descending) then send the acceleration/velocity. In this way the client receive the real time - 1 position.

A fgms fork is maybe the good solution but I'm not sure to have enough skills for that...

Cheers,
Clément
User avatar
F-JJTH
 
Posts: 696
Joined: Fri Sep 09, 2011 12:02 pm

Re: Populate AI Traffic with real traffic

Postby stuart » Fri Oct 12, 2012 9:59 am

Hi Clément,

Thanks for the source - I'll have a look at it over the weekend. I'm very interested in participating, though I have a slight concern about using data from the websites without permission. Have you spoken to anyone at the source websites about using their JSON feeds in this way?

Some immediate thoughts on your questions:

- My tool is here to generate AI traffic but since he send packet in MP every aircraft are considered like MP traffic not like AI traffic. I prefer to see these aircraft as AI traffic (it means to include it into flightgear source)

Yes, I think that makes a lot of sense. This should be a fairly straightforward change to make - just a marker on the MP traffic and a filter on the FG side.

- My tool send position of worldwide aircraft to every client but the client situated at Paris is not interested by the aircraft situated at New York. (it means to receive position of client and send only aircraft position within 100nm for example)


That should be straightforward to add if your server can receive MP information. Then it might be possible to plug a single fgais instance in the MP network.

- My tool is not able to update position of aircraft. Each 6 seconds every aircrafts are deleted then re-sent like new aircraft. I can't compare previous position with current position for example. it's a big problem because acceleration/velocity calculation is impossible.
- My tool should send aircraft position of the previous position in order to keep a position in advance for interpolation calculation. Currently my tool parse aircraft position then send them over MP. But he should parse aircraft position, then parse a second time aircraft position in order to know if the aircraft is moving (heading change, climbing, descending) then send the acceleration/velocity. In this way the client receive the real time - 1 position.


That should be fairly easily solvable. I'll probably take a look at this first.

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

Re: Populate AI Traffic with real traffic

Postby Hooray » Fri Oct 12, 2012 11:13 am

- My tool is here to generate AI traffic but since he send packet in MP every aircraft are considered like MP traffic not like AI traffic. I prefer to see these aircraft as AI traffic (it means to include it into flightgear source)

Like Stuart said, that's a simple change - but the question is if we WANT to do that (scraping the API at the client-side, i.e. fgfs): Stuart mentioned his concerns regarding "scraping" the JSON API here. The API provider may surely be affected by dozens of fgfs clients scraping his API like that simulatenously, especially given the amount of traffic. On the other hand, scraping the API by just a single process (i.e. fgms) and distributing the data via the MP protocol, would not be as invasive.

So, I'd make sure to keep such considerations in mind - web APIs like JSON are usually metered based on requests per second/minute. The API provider may be fine about us doing that once per second, but probably not dozens of times per second, from multiple contents/countries - which would equal a DDoS attack in a worst case scenario. However, we would obviosuly want to make sure that the API provider is not in any way affected by us using his data feeds like this.

I know, I've been told more than once that my postings sound like "lecturing" people at times - but, I'd still suggest to keep basic software design rules in mind here - otherwise, we may be spending time developing this feature, only to get the API use privileges restricted (or even revoked) shortly thereafter, because the API provider wasn't aware of our "broken design" and the implications of it onto his business.

Just some food for thought ...
Don't get me wrong, I don't disagree with the feature at all - just the way it's implemented currently, I am simply not sure if it's future-proof.
Personally, I'd hate developing this feature only to get a notice saying that the API use needs to be restricted to 10 simultaneous clients ...
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Fri Oct 12, 2012 12:27 pm

Stuart,

stuart wrote in Fri Oct 12, 2012 9:59 am:though I have a slight concern about using data from the websites without permission. Have you spoken to anyone at the source websites about using their JSON feeds in this way?

It was why I wouldn't release the source code... And I was persuaded to received this kind of "warning" from someone.
I had sent a mail to planefinder.net in order to tell what I want to do. Unfortunaltely I haven't received answer... Without prohibition from them I consider that's authorized... Also the consultation of their website is a free access. My tool just accessing to their data like million of person who access at their website. I don't store any data in DB or whatever it's just a consultation tool.

If it's a problem for FlightGear I can continue my work alone and use it only for me without sharing the source code and the binary and consider this tool like a restricted tool.

Here is the mail I sent to support (support@pinkfroot.com) :
Hello,

I'm involved in the free and open source FlightGear Flight Simulator under GNU GPL licence. I plan to work on a new feature for our flight simulator : display real traffic in real time.
This new feature adds a lot of realism to the flight simulator since the user can fly with real flights in real time.

Before starting to implement this new feature I would like to know if you would be ready to authorize FlightGear to use your data available on "planefinder.net" and "shipfinder.co" ?

Technically we just need a script which list all aircrafts / ships position in a limited area.
This is an example of link who provide ships position and others informations : http://www.marinetraffic.com/ais/export ... imespan=10 (JSON format)
Another format (XML) : http://www.marinetraffic.com/ais/export ... imespan=10

Each FlightGear client will have an HTTP script which send a request each X minutes to your server and parse the response from your script (we are able to calculate and create the movement of the plane/ship between 2 requests)
If you are able to provide these data in JSON format it should be perfect :
For aircrafts : latitude, longitude, altitude, orientation (course), speed, callsign (registration), model, transponder (squawk), route (departure/arrival)
For ships : latitude, longitude, orientation (course), speed, type, callsign


Let me know if you are interested and what kind of condition suggest you for this ?


Best regards,

Clément de l'Hamaide


As we said : now the ball is in their camp :)


Yes, I think that makes a lot of sense. This should be a fairly straightforward change to make - just a marker on the MP traffic and a filter on the FG side.

It requiere to touch fgms source code and flightgear source code but it's indeed the good solution. The question is who is ready and authorized to touch fgms source code and flightgear source code :)

That should be straightforward to add if your server can receive MP information. Then it might be possible to plug a single fgais instance in the MP network.

Currently fgais is not able to receive/interpret MP information. In fact fgms does the job for me since he calculate the "out of range" limit. In fact for local test I have fgais(send world wide aircraft position) ---> fgms(send only aircraft in area) ---> fgfs


Hooray,

I'm agree your point of view. As you said the good solution is to use fgais like a server and not like a client in order to limit the number of request to the provider.
I think that the good solution is :

1) fgais should send request to the provider every 20 seconds (the provider send new aircraft position every 20 seconds, if you send a request every 5 seconds you receive exactly the same result 4 times)
2) fgais should calculate the move of each aircraft in order to interpolate/calculate the position between each request to the provider. (We receive "real" position of aircrafts every 20 seconds but we calculate the new position every 4 seconds = 5 "fictive" position for 1 "real" position.
3) fgais should be able to send aircraft position only in area of the user (need to receive position of the client and calculate the "out of range" limit. This should be easy to use fgms implementation)
4) fgais should be able to send aircraft position as AI traffic instead of MP traffic (need to create a new "Magic Header" like it's already done in fgms for relay/tracker and add a filter in flightgear in order to make the difference between AI traffic and MP traffic.


Cheers,
Clément
User avatar
F-JJTH
 
Posts: 696
Joined: Fri Sep 09, 2011 12:02 pm

Re: Populate AI Traffic with real traffic

Postby Philosopher » Fri Oct 12, 2012 3:33 pm

What about having the airplane delayed by a bit (e.g. show it 3 seconds behind it's real position) so that we could have time to calculate better interpolations and have it (more) smoothly go to the next position if the calculated one was off? This might be a bad idea but the flightgear user shouldn't notice anything "wrong" with it being a bit behind, they should only notice if a big correction was needed from the calculated path.

I like this idea, Clément, thanks for suggesting and working on it!

P.S. What kind of information do we receive? I suppose we probably can't get pitch and roll, right?
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: Populate AI Traffic with real traffic

Postby Hooray » Fri Oct 12, 2012 3:57 pm

Nope, just positional information - no orientation (pitch,roll,yaw) - to come up with plausible values for these, one could use a lookup table for different types of aircraft, and then check the history of speeds (groundspeed, vertical speed, rate of turn), so that the 3D model could be oriented plausibly, depending on the trend of speeds.

Obviously, some "guessing" would still be involved to deal with aircraft-specific details like the current configuration (flaps, slats, gear, lights etc).
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Next

Return to AI Traffic

Who is online

Users browsing this forum: No registered users and 5 guests