AI Systems: Difference between revisions

Jump to navigation Jump to search
→‎AI Models: changed all tags to lowercase, which as of 1.9.1 seems to be what actually works.
(Category:FlightGear feature)
(→‎AI Models: changed all tags to lowercase, which as of 1.9.1 seems to be what actually works.)
Line 16: Line 16:
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/sinks, static 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):  
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/sinks, static 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>
  <ai>
   <ENABLED type="bool">true</ENABLED>
   <enabled type="bool">true</enabled>
   <SCENARIO>aircraft_demo</SCENARIO>
   <scenario>aircraft_demo</scenario>
  </AI>
  </ai>


The above bit of XML enables the AI system and selects a scenario file called aircraft_demo.xml.
The above bit of XML enables the AI system and selects a scenario file called aircraft_demo.xml.
''Notes:
*XML tags are <i>case-sensitive</i>.
*Introducing certain characters into the XML file, even as part of a comment, will cause the file to choke.  These include &, <, and --.''


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:
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>
  <entry>
   <TYPE>ship</TYPE>
   <type>ship</type>
   <MODEL>Models/Geometry/sailboat.xml</MODEL>  
   <model>models/geometry/sailboat.xml</model>  
   <SPEED-KTAS type="double">12.0</SPEED-KTAS>  
   <speed-ktas type="double">12.0</speed-ktas>  
   <ALTITUDE-FT type="double">0.0</ALTITUDE-FT>     
   <altitude-ft type="double">0.0</altitude-ft>     
   <LONGITUDE type="double">-122.33333</LONGITUDE>  
   <longitude type="double">-122.33333</longitude>  
   <LATITUDE type="double">37.61667</LATITUDE>
   <latitude type="double">37.61667</latitude>
   <HEADING type="double">20.0</HEADING>
   <heading type="double">20.0</heading>
  </ENTRY>
  </entry>




Line 39: Line 43:


  <!-- puts an A-4 north of KSFO, orbiting at 7000 ft -->   
  <!-- puts an A-4 north of KSFO, orbiting at 7000 ft -->   
  <ENTRY>
  <entry>
   <TYPE>aircraft</TYPE>
   <type>aircraft</type>
   <CLASS>light</CLASS>  
   <class>light</class>  
   <MODEL>Aircraft/a4/Models/a4-blue.xml</MODEL>  
   <model>Aircraft/a4/Models/a4-blue.xml</model>  
   <SPEED-KTAS type="double">320.0</SPEED-KTAS>  
   <speed-ktas type="double">320.0</speed-ktas>  
   <ALTITUDE-FT type="double">7000.0</ALTITUDE-FT>  
   <altitude-ft type="double">7000.0</altitude-ft>  
   <LONGITUDE type="double">-122.6</LONGITUDE>  
   <longitude type="double">-122.6</longitude>  
   <LATITUDE type="double">37.9</LATITUDE>
   <latitude type="double">37.9</latitude>
   <HEADING type="double">210.0</HEADING>  
   <heading type="double">210.0</heading>  
   <BANK type="double">-15.0</BANK>
   <bank type="double">-15.0</bank>
  </ENTRY>
  </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:
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>
  <entry>
   <TYPE>aircraft</TYPE>  
   <type>aircraft</type>  
   <CLASS>jet-transport</CLASS>
   <class>jet-transport</class>
   <MODEL>Aircraft/737/Models/737.xml</MODEL>
   <model>Aircraft/737/Models/737.xml</model>
   <FLIGHTPLAN>KSFO_ILS28L.xml</FLIGHTPLAN>  
   <flightplan>ksfo_ils28l.xml</flightplan>  
  </ENTRY>
  </entry>


To make a thunderstorm, use this:
To make a thunderstorm, use this:


  <!-- puts a thunderstorm overhead OSI (Woodside VOR) -->
  <!-- puts a thunderstorm overhead OSI (Woodside VOR) -->
  <ENTRY>
  <entry>
   <TYPE>storm</TYPE>
   <type>storm</type>
   <MODEL>Models/Geometry/thunderstorm.xml</MODEL>  
   <model>Models/Geometry/thunderstorm.xml</model>  
   <SPEED-KTAS type="double">20.0</SPEED-KTAS>  
   <speed-ktas type="double">20.0</speed-ktas>  
   <ALTITUDE-FT type="double">4000.0</ALTITUDE-FT>
   <altitude-ft type="double">4000.0</altitude-ft>
   <LATITUDE type="double">37.3917</LATITUDE>  
   <latitude type="double">37.3917</latitude>  
   <LONGITUDE type="double">-122.2817</LONGITUDE>  
   <longitude type="double">-122.2817</longitude>  
   <HEADING type="double">90</HEADING>
   <heading type="double">90</heading>
  </ENTRY>
  </entry>


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


  <ENTRY>
  <entry>
   <TYPE>thermal</TYPE>
   <type>thermal</type>
   <LATITUDE type="double">37.61633</LATITUDE>  
   <latitude type="double">37.61633</latitude>  
   <LONGITUDE type="double">-122.38334</LONGITUDE>  
   <longitude type="double">-122.38334</longitude>  
   <STRENGTH-FPS type="double">8.33</STRENGTH-FPS>  
   <strength-fps type="double">8.33</strength-fps>  
   <DIAMETER-FT type="double">4000</DIAMETER-FT>  
   <diameter-ft type="double">4000</diameter-ft>  
   <HEIGHT-MSL>6000</HEIGHT-MSL>
   <height-msl>6000</height-msl>
   <MODEL>Models/Geometry/thermalcap.xml</MODEL>
   <model>Models/Geometry/thermalcap.xml</model>
  </ENTRY>
  </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
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.   
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 and wind included). Try this:
A ballistic AI object starts with an initial azimuth, elevation and speed, then follows a ballistic path from there (with air resistance and wind included). Try this:


  <ENTRY>
  <entry>
   <TYPE>ballistic</TYPE>  
   <type>ballistic</type>  
   <MODEL>Models/Geometry/rocket.xml</MODEL>
   <model>Models/Geometry/rocket.xml</model>
   <SPEED-FPS type="double">500.0</SPEED-FPS>  
   <speed-fps type="double">500.0</speed-fps>  
   <ALTITUDE-FT type="double">50.0</ALTITUDE-FT>  
   <altitude-ft type="double">50.0</altitude-ft>  
   <LONGITUDE type="double">-122.39</LONGITUDE>  
   <longitude type="double">-122.39</longitude>  
   <LATITUDE type="double">37.62</LATITUDE>  
   <latitude type="double">37.62</latitude>  
   <HEADING type="double">200.0</HEADING>
   <heading type="double">200.0</heading>
   <AZIMUTH type="double">70.0</AZIMUTH>  
   <azimuth type="double">70.0</azimuth>  
   <ELEVATION type="double">45.0</ELEVATION>  
   <elevation type="double">45.0</elevation>  
  </ENTRY>
  </entry>
 


Note that the speed is now in feet per second.
Note that the speed is now in feet per second.
482

edits

Navigation menu