2004-06-25 11:15:17 +00:00
|
|
|
<HTML>
|
|
|
|
<HEAD></HEAD>
|
|
|
|
<BODY>
|
2005-10-27 08:28:15 +00:00
|
|
|
<h3>Using AI objects in FlightGear</h3><hr>
|
|
|
|
<br><br>
|
|
|
|
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 <b><tt>preferences.xml</tt></b> file, or
|
|
|
|
in an airplane's <b><tt>*-set.xml</tt></b> file. In later versions of FlightGear they are
|
|
|
|
defined in a "scenario file" only. Types of AI objects available are ships, airplanes,
|
|
|
|
thunderstorms, thermals, aircraft carriers, static and ballistic objects.
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
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
|
|
|
|
<b><tt>data/Data/AI</tt></b> directory. You select which scenario file you want to use by naming
|
|
|
|
it in the <b><tt>preferences.xml</tt></b> file. (Note: As with everything in the
|
|
|
|
<b><tt>preferences.xml</tt></b> file, the entries can be overridden by an aircraft's
|
|
|
|
<b><tt>*-set.xml</tt></b> file, or at the command line.) The <b><tt>preferences.xml</tt></b>
|
|
|
|
file has an entry that looks like this (FlightGear versions newer than 0.9.4):
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
<b><tt>
|
2004-06-25 11:15:17 +00:00
|
|
|
<ai><br>
|
2005-10-27 08:28:15 +00:00
|
|
|
<enabled type="bool">true</enabled><br>
|
|
|
|
<scenario>demo_scenario</scenario><br>
|
2004-06-25 11:15:17 +00:00
|
|
|
</ai><br>
|
2005-10-27 08:28:15 +00:00
|
|
|
</tt></b>
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
The scenario contains one entry for each AI object. The entry specifies what kind of
|
|
|
|
object to create, what it's initial conditions will be, and optionally (for aircraft and
|
|
|
|
ships) a flight plan.
|
|
|
|
<BR><BR><BR>
|
|
|
|
|
|
|
|
<h3>Ships</h3><hr>
|
|
|
|
The entry to create a sailboat would look like this:
|
|
|
|
<br><br>
|
|
|
|
|
|
|
|
<b><tt>
|
|
|
|
<entry><br>
|
|
|
|
<type>ship</type><br>
|
2008-03-11 10:27:50 +00:00
|
|
|
<path>AI/Aircraft/sailboat1/sailboat.xml</path><br>
|
2005-10-27 08:28:15 +00:00
|
|
|
<speed type="double">12.0</speed><br>
|
|
|
|
<altitude type="double">0.0</altitude><br>
|
|
|
|
<longitude type="double">-122.33333</longitude><br>
|
|
|
|
<latitude type="double">37.61667</latitude><br>
|
|
|
|
<heading type="double">20.0</heading><br>
|
|
|
|
<rudder type="double">-3.0</rudder><br>
|
|
|
|
</entry><br>
|
|
|
|
</tt></b>
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
Most of the entries are self-explanatory. The "type" of object can be one of "aircraft",
|
|
|
|
"ship", "storm", "thermal", "carrier", "static" or "ballistic". The rest of the items
|
|
|
|
give the AI object a model, a starting location, and a starting speed and direction. You
|
|
|
|
use the <b><path></b> 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
|
|
|
|
<b><rudder></b> 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).
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
<h3>Aircraft</h3><hr>
|
|
|
|
Here is an example of how to create an aircraft AI object:
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
<b><tt>
|
2004-06-25 11:15:17 +00:00
|
|
|
<!-- puts an A-4 north of KSFO, orbiting at 7000 ft --><br>
|
|
|
|
<entry><br>
|
2005-10-27 08:28:15 +00:00
|
|
|
<type>aircraft</type><br>
|
|
|
|
<class>jet_fighter</class><br>
|
|
|
|
<path>Aircraft/a4/Models/a4-blue.xml</path><br>
|
|
|
|
<speed type="double">320.0</speed><br>
|
|
|
|
<altitude type="double">7000.0</altitude><br>
|
|
|
|
<longitude type="double">-122.6</longitude><br>
|
|
|
|
<latitude type="double">37.9</latitude><br>
|
|
|
|
<heading type="double">210.0</heading><br>
|
|
|
|
<roll type="double">-15.0</roll><br>
|
2004-06-25 11:15:17 +00:00
|
|
|
</entry>
|
2005-10-27 08:28:15 +00:00
|
|
|
</tt></b>
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
It looks much the same as the ship AI code. There are two differences, the
|
|
|
|
<b><class></b> item and the <b><roll></b> item. If the class is set to
|
|
|
|
"tanker" the airplane will allow you to refuel if you can get close behind it (so far
|
|
|
|
supported by JSBSim only) The "roll" will cause the airplane to fly in a circle. 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, or (new since version 0.9.8)
|
|
|
|
the object can be set to endlessly repeat a flight plan. The flight plans are located in
|
|
|
|
<b><tt>data/Data/AI/FlightPlans</tt></b>. To create an airplane with a flightplan do this:
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
<b><tt>
|
2004-06-25 11:15:17 +00:00
|
|
|
<entry><br>
|
2005-10-27 08:28:15 +00:00
|
|
|
<type>aircraft</type><br>
|
|
|
|
<class>jet-transport</class><br>
|
|
|
|
<path>Aircraft/737/Models/737.xml</path><br>
|
|
|
|
<flightplan>KSFO_ILS28L.xml</flightplan><br>
|
2004-06-25 11:15:17 +00:00
|
|
|
</entry><br>
|
2005-10-27 08:28:15 +00:00
|
|
|
</tt></b>
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
In this case you don't need to specify initial conditions because they are already defined
|
|
|
|
in the flight plan. The AI aircraft objects can be displayed on radar. See the
|
|
|
|
<b><tt>Aircraft/Instruments/radar.xml</tt></b> file for details.
|
|
|
|
|
|
|
|
<BR><BR>
|
|
|
|
<h3>Thunderstorms</h3><hr>
|
|
|
|
<BR>
|
|
|
|
To make a thunderstorm, use this:
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
<b><tt>
|
|
|
|
<!-- puts a thunderstorm overhead OSI (Woodside VOR) --><br>
|
|
|
|
<entry><br>
|
|
|
|
<type>storm</type><br>
|
|
|
|
<path>Models/Geometry/thunderstorm.xml</path><br>
|
|
|
|
<speed type="double">20.0</speed><br>
|
|
|
|
<altitude type="double">4000.0</altitude><br>
|
|
|
|
<latitude type="double">37.3917</latitude><br>
|
|
|
|
<longitude type="double">-122.2817</longitude><br>
|
|
|
|
<heading type="double">90</heading><br>
|
|
|
|
</entry><br>
|
|
|
|
</tt></b>
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
There's not much to it. No, they don't turn :) New since version 0.9.8 is the ability
|
|
|
|
to add lightning and turbulence to a thunderstorm. For an example of this see the scenario
|
|
|
|
file called "bigstorm_demo.xml". The AI storm objects can be displayed on weather radar. See the
|
|
|
|
<b><tt>Aircraft/Instruments/wxradar.xml</tt></b> file for details.
|
|
|
|
|
|
|
|
<br><br>
|
|
|
|
<h3>Thermals</h3><hr>
|
|
|
|
<BR>
|
|
|
|
To create a thermal, use this:
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
<b><tt>
|
2004-06-25 11:15:17 +00:00
|
|
|
<!-- puts a thermal over the control tower at KSFO --><br>
|
|
|
|
<entry><br>
|
2005-10-27 08:28:15 +00:00
|
|
|
<type>thermal</type><br>
|
|
|
|
<latitude type="double">37.61633</latitude><br>
|
|
|
|
<longitude type="double">-122.38334</longitude><br>
|
|
|
|
<strength-fps type="double">8.33</strength-fps><br>
|
|
|
|
<diameter-ft type="double">4000.0</diameter-ft><br>
|
|
|
|
<height-msl type="double">6000.0</height-msl><br>
|
2004-06-25 11:15:17 +00:00
|
|
|
</entry><br>
|
2005-10-27 08:28:15 +00:00
|
|
|
</tt></b>
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
The AI thermals don't move, they are invisible, and they don't "lean" downwind.
|
|
|
|
The <b><strength-fps></b> defines the maximum vertical velocity of the airmass
|
|
|
|
at the center of the thermal. The strength decreases to zero at the thermal's edge.
|
|
|
|
<b><height-msl></b> defines the top of the thermal.
|
|
|
|
|
|
|
|
|
|
|
|
<br><br>
|
|
|
|
<h3>Ballistic objects</h3><hr>
|
|
|
|
<br>
|
|
|
|
A ballistic AI object starts with an initial location, azimuth, elevation and speed, then
|
|
|
|
follows a ballistic path from there (with air resistance included). Try this:
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
<b><tt>
|
|
|
|
<entry><br>
|
|
|
|
<type>ballistic</type><br>
|
|
|
|
<path>Models/Geometry/rocket.xml</path><br>
|
|
|
|
<speed type="double">500.0</speed><br>
|
|
|
|
<altitude type="double">50.0</altitude><br>
|
|
|
|
<longitude type="double">-122.39</longitude><br>
|
|
|
|
<latitude type="double">37.62</latitude><br>
|
|
|
|
<heading type="double">200.0</heading><br>
|
|
|
|
<azimuth type="double">70.0</azimuth><br>
|
|
|
|
<elevation type="double">45.0</elevation><br>
|
|
|
|
</entry><br>
|
|
|
|
</tt></b>
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR>
|
|
|
|
|
2005-10-27 08:28:15 +00:00
|
|
|
There is not much call for rocket launches in FlightGear, but the ballistic AI object is
|
|
|
|
the basis for FlightGear's <a href="README.submodels">submodels</a> system.
|
|
|
|
|
|
|
|
<BR><BR><BR>
|
|
|
|
<h3>Aircraft Carriers</h3><hr>
|
|
|
|
<br>
|
|
|
|
The aircraft carrier AI object is based on the "ship" object but is much more complicated.
|
|
|
|
See the scenario file called <b><tt>nimitz_demo.xml</tt></b> for details.
|
2004-06-25 11:15:17 +00:00
|
|
|
<BR><BR><BR>
|
|
|
|
<hr>
|
2005-10-27 08:28:15 +00:00
|
|
|
Dave Culp, updated 23 Oct 2005<br>
|
|
|
|
davidculp2@comcast.net
|
2004-06-25 11:15:17 +00:00
|
|
|
</BODY>
|
|
|
|
</HTML>
|