AI Systems

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

Jump to: navigation, search


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.


  • 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


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):

 <ENABLED type="bool">true</ENABLED>

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:

 <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>

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:

 <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>

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:


To make a thunderstorm, use this:

  <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>

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

 <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> 

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:

 <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> 

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 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.