AI Systems

From FlightGear wiki
Revision as of 12:49, 10 June 2006 by 71.194.220.188 (Talk) (Submodels)

Jump to: navigation, search

ATC

FlightGear has a simple Air Traffic Control system.

For airports with a tower frequency, if that frequency is tuned in to your radio, you may contact ATC.

To obtain the tower frequencies for an airport within range of ATC, go to the ATC/AI menu, choose Frequencies to display the dialog. If there are any airports within 40mn range, a button with the airport designation will appear. Click see the frequencies. Tune the tower frequency in on the COM1 radio and then hit the single quote key to open the ATC window.


Points:

  • Untowered airports are not supported in any way by ATC.
  • You must be within 40 nautical miles of an ATC facility (towered airport with tower frequencies) to contact ATC.

AI Air Traffic

Todo

AI Models

Starting with FlightGear version 0.9.4 you can place AI objects in the "FlightGear world". In version 0.9.4 the AI objects can be defined in the preferences.xml file, or in an airplane's *-set.xml file. In later versions they are defined in a "scenario file" only. The types of AI objects you can have are airplanes, ships, thunderstorms, thermals and ballistic objects. AI objects have some things in common: The have a location in the "FlightGear world", they can have an associated exterior 3D model, and they can move according to an internal FDM (flight dynamics model). As of now, these objects are created at simulator start-up by adding some XML code to a scenario file. The scenario file must be in the data/AI directory. You select which scenario files you want to use by naming it in the preferences.xml file. The preferences.xml file has an entry that looks like this (FlightGear versions newer than 0.9.4, including CVS):

<AI>
 <ENABLED type="bool">true</ENABLED>
 <SCENARIO>aircraft_demo</SCENARIO>
</AI>

The above bit of XML enables the AI system and selects a scenario file called aircraft_demo.xml.


The scenario file contains one entry for each AI object. The entry specifies what kind of object to create, what its initial conditions will be, and optionally (for aircraft and ships) a flight plan. The entry for a sailboat could look like this:

<ENTRY>
 <TYPE>ship</TYPE>
 <MODEL>Models/Geometry/sailboat.xml</MODEL> 
 <SPEED-KTAS type="double">12.0</SPEED-KTAS> 
 <ALTITUDE-FT type="double">0.0</ALTITUDE-FT>    
 <LONGITUDE type="double">-122.33333</LONGITUDE> 
 <LATITUDE type="double">37.61667</LATITUDE>
 <HEADING type="double">20.0</HEADING>
</ENTRY>


Most of the parameters are self-explanitory. The "type" of object can be one of "aircraft", "ship", "storm", "thermal", "ballistic" or "static". The rest of the items give the AI object a model, a starting location, and a starting speed and direction. You use the <MODEL> item to give the object any valid exterior model. You can even make the ship look like an airplane if you want! The "ship" type can also have a <RUDDER> value specified, which will cause the ship to move in a circle (HINT: use small values, five degrees or less, and right rudder is positive). Here is an example of how to create an aircraft AI object:

<ENTRY>
 <TYPE>aircraft</TYPE>
 <CLASS>light</CLASS> 
 <MODEL>Aircraft/a4/Models/a4-blue.xml</MODEL> 
 <SPEED-KTAStype="double">320.0</SPEED-KTAS> 
 <ALTITUDE-FT type="double">7000.0</ALTITUDE-FT> 
 <LONGITUDE type="double">-122.6</LONGITUDE> 
 <LATITUDE type="double">37.9</LATITUDE>
 <HEADING type="double">210.0</HEADING> 
 <BANK type="double">-15.0</BANK>
</ENTRY>


It looks much the same as the ship AI code. There are two differences, the <CLASS> item and the <BANK> item. If the class is set to "tanker" the airplane will allow you to refuel if you can get close behind it. The bank is of course similar to the ship's rudder. In the above example the A-4 will be orbiting to the left at 15 degrees of bank. You can also create a ship or airplane with a flight plan. In this case the object will follow the flight plan, and then delete itself when it reaches the end. The flight plans are kept in data/Data/AI/FlightPlans. To create an airplane with a flightplan do this:

<ENTRY>
 <TYPE>aircraft</TYPE> 
 <CLASS>jet-transport</CLASS>
 <MODEL>Aircraft/737/Models/737.xml</MODEL>
 <FLIGHTPLAN>KSFO_ILS28L.xml</FLIGHTPLAN> 
</ENTRY>

To make a thunderstorm, use this:

<ENTRY>
  <TYPE>storm</TYPE>
  <MODEL>Models/Geometry/thunderstorm.xml</MODEL> 
  <SPEED-KTAS type="double">20.0</SPEED-KTAS> 
  <ALTITUDE-FT type="double">4000.0</ALTITUDE-FT>
  <LATITUDE type="double">37.3917</LATITUDE> 
  <LONGITUDE type="double">-122.2817</LONGITUDE> 
  <HEADING type="double">90</HEADING>
</ENTRY>

There's not much to it. No, they don't turn :) To create a thermal, use this:

<ENTRY>
 <TYPE>thermal</TYPE>
 <LATITUDE type="double">37.61633</LATITUDE> 
 <LONGITUDE type="double">-122.38334</LONGITUDE> 
 <STRENGTH-FPS type="double">8.33</STRENGTH-FPS> 
 <DIAMETER-FT type="double">4000</DIAMETER-FT> 
 <HEIGHT-MSL>6000</HEIGHT-MSL>
 <MODEL>Models/Geometry/thermalcap.xml</MODEL>
</ENTRY>

The AI thermals don't move, they are invisible, and they don't "lean" downwind. The <STRENGTH-FPS> defines the maximum vertical velocity of the airmass at the center of the thermal. The strength decreases to zero at the thermal's edge. A model can be assigned to the thermal, and usually this will be a small cloud to mark the thermal's location. To create a sink, just give a "thermal" a negative strength, and give it a null model. Please see the demo scenario (thermal_demo.xml) for examples.

A ballistic AI object starts with an initial azimuth, elevation and speed, then follows a ballistic path from there (with air resistance included). Try this:

<ENTRY>
 <TYPE>ballistic</TYPE> 
 <MODEL>Models/Geometry/rocket.xml</MODEL>
 <SPEED-FPS type="double">500.0</SPEED-FPS> 
 <ALTITUDE-FT type="double">50.0</ALTITUDE-FT> 
 <LONGITUDE type="double">-122.39</LONGITUDE> 
 <LATITUDE type="double">37.62</LATITUDE> 
 <HEADING type="double">200.0</HEADING>
 <AZIMUTH type="double">70.0</AZIMUTH> 
 <ELEVATION type="double">45.0</ELEVATION> 
</ENTRY>

The AI storm objects can be displayed on weather radar. See the Aircraft/Instruments/wxradar.xml file for details. The AI aircraft objects can be displayed on radar. See the Aircraft/Instruments/radar.xml file for details, or fly the T-38 for a demo.

Submodels

Submodels are AI ballistic objects that emanate from, fall from, or launch from the user aircraft. They are presently used to model smoke, contrails, flares, tracers, bombs, drop tanks and flight path markers.

Submodels are controlled by the submodel manager. The manager reads a submodel configuration file at the start of the sim session. This configuration file is written by the aircraft author and defines all the submodels for that particular aircraft.

As an example examine the submodels file in the Aircraft/737-300 directory. This file creates two submodels which will become the airplane's left and right engine contrails. Each contrail needs its own submodel definition because the contrails begin at different locations. Each contrail consists of a train of individual "puff" models that are released in rapid succession as long as the "trigger" property is true. We ensure an unlimited supply of puffs by setting the "count" parameter to -1. The individual puffs, being AIBallistic objects, will follow their own ballistic paths once released. In this case we have used the "bouyancy" parameter to negate gravity in the ballistic path. The puffs have been given a life span of eight seconds. At cruising speed the 737 will thus have about 400 puffs behind it at any moment.