| 1 | <HTML> |
| 2 | <HEAD></HEAD> |
| 3 | <BODY> |
| 4 | <h3>Using AI objects in FlightGear</h3><hr> |
| 5 | <br><br> |
| 6 | Starting with FlightGear version 0.9.4 you can place AI objects in the "FlightGear world". |
| 7 | In version 0.9.4 the AI objects can be defined in the <b><tt>preferences.xml</tt></b> file, or |
| 8 | in an airplane's <b><tt>*-set.xml</tt></b> file. In later versions of FlightGear they are |
| 9 | defined in a "scenario file" only. Types of AI objects available are ships, airplanes, |
| 10 | thunderstorms, thermals, aircraft carriers, static and ballistic objects. |
| 11 | <BR><BR> |
| 12 | |
| 13 | AI objects have some things in common: The have a location in the "FlightGear world", |
| 14 | they can have an associated exterior 3D model, and they can move according to an internal |
| 15 | FDM (flight dynamics model). As of now, these objects are created at simulator start-up |
| 16 | by adding some XML code to a scenario file. The scenario file must be in the |
| 17 | <b><tt>data/Data/AI</tt></b> directory. You select which scenario file you want to use by naming |
| 18 | it in the <b><tt>preferences.xml</tt></b> file. (Note: As with everything in the |
| 19 | <b><tt>preferences.xml</tt></b> file, the entries can be overridden by an aircraft's |
| 20 | <b><tt>*-set.xml</tt></b> file, or at the command line.) The <b><tt>preferences.xml</tt></b> |
| 21 | file has an entry that looks like this (FlightGear versions newer than 0.9.4): |
| 22 | <BR><BR> |
| 23 | |
| 24 | <b><tt> |
| 25 | <ai><br> |
| 26 | <enabled type="bool">true</enabled><br> |
| 27 | <scenario>demo_scenario</scenario><br> |
| 28 | </ai><br> |
| 29 | </tt></b> |
| 30 | <BR><BR> |
| 31 | |
| 32 | The scenario contains one entry for each AI object. The entry specifies what kind of |
| 33 | object to create, what it's initial conditions will be, and optionally (for aircraft and |
| 34 | ships) a flight plan. |
| 35 | <BR><BR><BR> |
| 36 | |
| 37 | <h3>Ships</h3><hr> |
| 38 | The entry to create a sailboat would look like this: |
| 39 | <br><br> |
| 40 | |
| 41 | <b><tt> |
| 42 | <entry><br> |
| 43 | <type>ship</type><br> |
| 44 | <path>AI/Aircraft/sailboat1/sailboat.xml</path><br> |
| 45 | <speed type="double">12.0</speed><br> |
| 46 | <altitude type="double">0.0</altitude><br> |
| 47 | <longitude type="double">-122.33333</longitude><br> |
| 48 | <latitude type="double">37.61667</latitude><br> |
| 49 | <heading type="double">20.0</heading><br> |
| 50 | <rudder type="double">-3.0</rudder><br> |
| 51 | </entry><br> |
| 52 | </tt></b> |
| 53 | <BR><BR> |
| 54 | |
| 55 | Most of the entries are self-explanatory. The "type" of object can be one of "aircraft", |
| 56 | "ship", "storm", "thermal", "carrier", "static" or "ballistic". The rest of the items |
| 57 | give the AI object a model, a starting location, and a starting speed and direction. You |
| 58 | use the <b><path></b> item to give the object any valid exterior model. You can even |
| 59 | make the ship look like an airplane if you want! The "ship" type can also have a |
| 60 | <b><rudder></b> value specified, which will cause the ship to move in a circle |
| 61 | (HINT: use small values, five degrees or less, and right rudder is positive). |
| 62 | <BR><BR> |
| 63 | |
| 64 | <h3>Aircraft</h3><hr> |
| 65 | Here is an example of how to create an aircraft AI object: |
| 66 | <BR><BR> |
| 67 | |
| 68 | <b><tt> |
| 69 | <!-- puts an A-4 north of KSFO, orbiting at 7000 ft --><br> |
| 70 | <entry><br> |
| 71 | <type>aircraft</type><br> |
| 72 | <class>jet_fighter</class><br> |
| 73 | <path>Aircraft/a4/Models/a4-blue.xml</path><br> |
| 74 | <speed type="double">320.0</speed><br> |
| 75 | <altitude type="double">7000.0</altitude><br> |
| 76 | <longitude type="double">-122.6</longitude><br> |
| 77 | <latitude type="double">37.9</latitude><br> |
| 78 | <heading type="double">210.0</heading><br> |
| 79 | <roll type="double">-15.0</roll><br> |
| 80 | </entry> |
| 81 | </tt></b> |
| 82 | <BR><BR> |
| 83 | |
| 84 | It looks much the same as the ship AI code. There are two differences, the |
| 85 | <b><class></b> item and the <b><roll></b> item. If the class is set to |
| 86 | "tanker" the airplane will allow you to refuel if you can get close behind it (so far |
| 87 | supported by JSBSim only) The "roll" will cause the airplane to fly in a circle. In the |
| 88 | above example the A-4 will be orbiting to the left at 15 degrees of bank. You can also |
| 89 | create a ship or airplane with a flight plan. In this case the object will follow the |
| 90 | flight plan and then delete itself when it reaches the end, or (new since version 0.9.8) |
| 91 | the object can be set to endlessly repeat a flight plan. The flight plans are located in |
| 92 | <b><tt>data/Data/AI/FlightPlans</tt></b>. To create an airplane with a flightplan do this: |
| 93 | <BR><BR> |
| 94 | |
| 95 | <b><tt> |
| 96 | <entry><br> |
| 97 | <type>aircraft</type><br> |
| 98 | <class>jet-transport</class><br> |
| 99 | <path>Aircraft/737/Models/737.xml</path><br> |
| 100 | <flightplan>KSFO_ILS28L.xml</flightplan><br> |
| 101 | </entry><br> |
| 102 | </tt></b> |
| 103 | <BR><BR> |
| 104 | |
| 105 | |
| 106 | In this case you don't need to specify initial conditions because they are already defined |
| 107 | in the flight plan. The AI aircraft objects can be displayed on radar. See the |
| 108 | <b><tt>Aircraft/Instruments/radar.xml</tt></b> file for details. |
| 109 | |
| 110 | <BR><BR> |
| 111 | <h3>Thunderstorms</h3><hr> |
| 112 | <BR> |
| 113 | To make a thunderstorm, use this: |
| 114 | <BR><BR> |
| 115 | |
| 116 | <b><tt> |
| 117 | <!-- puts a thunderstorm overhead OSI (Woodside VOR) --><br> |
| 118 | <entry><br> |
| 119 | <type>storm</type><br> |
| 120 | <path>Models/Geometry/thunderstorm.xml</path><br> |
| 121 | <speed type="double">20.0</speed><br> |
| 122 | <altitude type="double">4000.0</altitude><br> |
| 123 | <latitude type="double">37.3917</latitude><br> |
| 124 | <longitude type="double">-122.2817</longitude><br> |
| 125 | <heading type="double">90</heading><br> |
| 126 | </entry><br> |
| 127 | </tt></b> |
| 128 | <BR><BR> |
| 129 | |
| 130 | There's not much to it. No, they don't turn :) New since version 0.9.8 is the ability |
| 131 | to add lightning and turbulence to a thunderstorm. For an example of this see the scenario |
| 132 | file called "bigstorm_demo.xml". The AI storm objects can be displayed on weather radar. See the |
| 133 | <b><tt>Aircraft/Instruments/wxradar.xml</tt></b> file for details. |
| 134 | |
| 135 | <br><br> |
| 136 | <h3>Thermals</h3><hr> |
| 137 | <BR> |
| 138 | To create a thermal, use this: |
| 139 | <BR><BR> |
| 140 | |
| 141 | <b><tt> |
| 142 | <!-- puts a thermal over the control tower at KSFO --><br> |
| 143 | <entry><br> |
| 144 | <type>thermal</type><br> |
| 145 | <latitude type="double">37.61633</latitude><br> |
| 146 | <longitude type="double">-122.38334</longitude><br> |
| 147 | <strength-fps type="double">8.33</strength-fps><br> |
| 148 | <diameter-ft type="double">4000.0</diameter-ft><br> |
| 149 | <height-msl type="double">6000.0</height-msl><br> |
| 150 | </entry><br> |
| 151 | </tt></b> |
| 152 | <BR><BR> |
| 153 | |
| 154 | The AI thermals don't move, they are invisible, and they don't "lean" downwind. |
| 155 | The <b><strength-fps></b> defines the maximum vertical velocity of the airmass |
| 156 | at the center of the thermal. The strength decreases to zero at the thermal's edge. |
| 157 | <b><height-msl></b> defines the top of the thermal. |
| 158 | |
| 159 | |
| 160 | <br><br> |
| 161 | <h3>Ballistic objects</h3><hr> |
| 162 | <br> |
| 163 | A ballistic AI object starts with an initial location, azimuth, elevation and speed, then |
| 164 | follows a ballistic path from there (with air resistance included). Try this: |
| 165 | <BR><BR> |
| 166 | |
| 167 | <b><tt> |
| 168 | <entry><br> |
| 169 | <type>ballistic</type><br> |
| 170 | <path>Models/Geometry/rocket.xml</path><br> |
| 171 | <speed type="double">500.0</speed><br> |
| 172 | <altitude type="double">50.0</altitude><br> |
| 173 | <longitude type="double">-122.39</longitude><br> |
| 174 | <latitude type="double">37.62</latitude><br> |
| 175 | <heading type="double">200.0</heading><br> |
| 176 | <azimuth type="double">70.0</azimuth><br> |
| 177 | <elevation type="double">45.0</elevation><br> |
| 178 | </entry><br> |
| 179 | </tt></b> |
| 180 | <BR><BR> |
| 181 | |
| 182 | There is not much call for rocket launches in FlightGear, but the ballistic AI object is |
| 183 | the basis for FlightGear's <a href="README.submodels">submodels</a> system. |
| 184 | |
| 185 | <BR><BR><BR> |
| 186 | <h3>Aircraft Carriers</h3><hr> |
| 187 | <br> |
| 188 | The aircraft carrier AI object is based on the "ship" object but is much more complicated. |
| 189 | See the scenario file called <b><tt>nimitz_demo.xml</tt></b> for details. |
| 190 | <BR><BR><BR> |
| 191 | <hr> |
| 192 | Dave Culp, updated 23 Oct 2005<br> |
| 193 | [email protected] |
| 194 | </BODY> |
| 195 | </HTML> |