]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/FGFDM.cpp
Don't fiddle with control positions at startup -- we can do that in
[flightgear.git] / src / FDM / YASim / FGFDM.cpp
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include <Main/fg_props.hxx>
5
6 #include "Jet.hpp"
7 #include "SimpleJet.hpp"
8 #include "Gear.hpp"
9 #include "Atmosphere.hpp"
10 #include "PropEngine.hpp"
11 #include "Propeller.hpp"
12 #include "PistonEngine.hpp"
13
14 #include "FGFDM.hpp"
15 namespace yasim {
16
17 // Some conversion factors
18 static const float KTS2MPS = 0.514444444444;
19 static const float FT2M = 0.3048;
20 static const float DEG2RAD = 0.0174532925199;
21 static const float RPM2RAD = 0.10471975512;
22 static const float LBS2N = 4.44822;
23 static const float LBS2KG = 0.45359237;
24 static const float KG2LBS = 2.2046225;
25 static const float CM2GALS = 264.172037284;
26 static const float HP2W = 745.700;
27 static const float INHG2PA = 3386.389;
28 static const float K2DEGF = 1.8;
29 static const float CIN2CM = 1.6387064e-5;
30
31 // Stubs, so that this can be compiled without the FlightGear
32 // binary.  What's the best way to handle this?
33
34 //     float fgGetFloat(char* name, float def) { return 0; }
35 //     void fgSetFloat(char* name, float val) {}
36
37 FGFDM::FGFDM()
38 {
39     _nextEngine = 0;
40
41     // Map /controls/elevator to the approach elevator control.  This
42     // should probably be settable, but there are very few aircraft
43     // who trim their approaches using things other than elevator.
44     _airplane.setElevatorControl(parseAxis("/controls/elevator-trim"));
45 }
46
47 FGFDM::~FGFDM()
48 {
49     int i;
50     for(i=0; i<_axes.size(); i++) {
51         AxisRec* a = (AxisRec*)_axes.get(i);
52         delete[] a->name;
53         delete a;
54     }
55     for(i=0; i<_thrusters.size(); i++) {
56         EngRec* er = (EngRec*)_thrusters.get(i);
57         delete[] er->prefix;
58         delete er->eng;
59         delete er;
60     }
61     for(i=0; i<_weights.size(); i++) {
62         WeightRec* wr = (WeightRec*)_weights.get(i);
63         delete[] wr->prop;
64         delete wr;
65     }
66     for(i=0; i<_controlProps.size(); i++)
67         delete (PropOut*)_controlProps.get(i);
68 }
69
70 void FGFDM::iterate(float dt)
71 {
72     getExternalInput(dt);
73     _airplane.iterate(dt);
74
75     if(fgGetBool("/sim/freeze/fuel") != true)
76         _airplane.consumeFuel(dt);
77
78     setOutputProperties();
79 }
80
81 Airplane* FGFDM::getAirplane()
82 {
83     return &_airplane;
84 }
85
86 void FGFDM::init()
87 {
88     // Allows the user to start with something other than full fuel
89     _airplane.setFuelFraction(fgGetFloat("/sim/fuel-fraction", 1));
90
91     // This has a nasty habit of being false at startup.  That's not
92     // good.
93     fgSetBool("/controls/gear-down", true);
94 }
95
96 // Not the worlds safest parser.  But it's short & sweet.
97 void FGFDM::startElement(const char* name, const XMLAttributes &atts)
98 {
99     XMLAttributes* a = (XMLAttributes*)&atts;
100     float v[3];
101     char buf[64];
102
103     if(eq(name, "airplane")) {
104         _airplane.setWeight(attrf(a, "mass") * LBS2KG);
105     } else if(eq(name, "approach")) {
106         float spd = attrf(a, "speed") * KTS2MPS;
107         float alt = attrf(a, "alt", 0) * FT2M;
108         float aoa = attrf(a, "aoa", 0) * DEG2RAD;
109         _airplane.setApproach(spd, alt, aoa);
110         _cruiseCurr = false;
111     } else if(eq(name, "cruise")) {
112         float spd = attrf(a, "speed") * KTS2MPS;
113         float alt = attrf(a, "alt") * FT2M;
114         _airplane.setCruise(spd, alt);
115         _cruiseCurr = true;
116     } else if(eq(name, "cockpit")) {
117         v[0] = attrf(a, "x");
118         v[1] = attrf(a, "y");
119         v[2] = attrf(a, "z");
120         _airplane.setPilotPos(v);
121     } else if(eq(name, "wing")) {
122         _airplane.setWing(parseWing(a, name));
123     } else if(eq(name, "hstab")) {
124         _airplane.setTail(parseWing(a, name));
125     } else if(eq(name, "vstab")) {
126         _airplane.addVStab(parseWing(a, name));
127     } else if(eq(name, "propeller")) {
128         parsePropeller(a);
129     } else if(eq(name, "thruster")) {
130         SimpleJet* j = new SimpleJet();
131         _currObj = j;
132         v[0] = attrf(a, "x"); v[1] = attrf(a, "y"); v[2] = attrf(a, "z");
133         j->setPosition(v);
134         _airplane.addThruster(j, 0, v);
135         v[0] = attrf(a, "vx"); v[1] = attrf(a, "vy"); v[2] = attrf(a, "vz");
136         j->setDirection(v);
137         j->setThrust(attrf(a, "thrust") * LBS2N);
138     } else if(eq(name, "jet")) {
139         Jet* j = new Jet();
140         _currObj = j;
141         v[0] = attrf(a, "x");
142         v[1] = attrf(a, "y");
143         v[2] = attrf(a, "z");
144         float mass = attrf(a, "mass") * LBS2KG;
145         j->setMaxThrust(attrf(a, "thrust") * LBS2N,
146                         attrf(a, "afterburner", 0) * LBS2N);
147         j->setVectorAngle(attrf(a, "rotate", 0) * DEG2RAD);
148
149         float n1min = attrf(a, "n1-idle", 55);
150         float n1max = attrf(a, "n1-max", 102);
151         float n2min = attrf(a, "n2-idle", 73);
152         float n2max = attrf(a, "n2-max", 103);
153         j->setRPMs(n1min, n1max, n2min, n2max);
154
155         j->setTSFC(attrf(a, "tsfc", 0.8));
156         if(a->hasAttribute("egt"))  j->setEGT(attrf(a, "egt"));
157         if(a->hasAttribute("epr"))  j->setEPR(attrf(a, "epr"));
158         if(a->hasAttribute("exhaust-speed"))
159             j->setVMax(attrf(a, "exhaust-speed") * KTS2MPS);
160         
161         j->setPosition(v);
162         _airplane.addThruster(j, mass, v);
163         sprintf(buf, "/engines/engine[%d]", _nextEngine++);
164         EngRec* er = new EngRec();
165         er->eng = j;
166         er->prefix = dup(buf);
167         _thrusters.add(er);
168     } else if(eq(name, "gear")) {
169         Gear* g = new Gear();
170         _currObj = g;
171         v[0] = attrf(a, "x");
172         v[1] = attrf(a, "y");
173         v[2] = attrf(a, "z");
174         g->setPosition(v);
175         v[0] = 0;
176         v[1] = 0;
177         v[2] = attrf(a, "compression", 1);
178         g->setCompression(v);
179         g->setBrake(attrf(a, "skid", 0));
180         g->setStaticFriction(attrf(a, "sfric", 0.8));
181         g->setDynamicFriction(attrf(a, "dfric", 0.7));
182         g->setSpring(attrf(a, "spring", 1));
183         g->setDamping(attrf(a, "damp", 1));
184         _airplane.addGear(g);
185     } else if(eq(name, "fuselage")) {
186         float b[3];
187         v[0] = attrf(a, "ax");
188         v[1] = attrf(a, "ay");
189         v[2] = attrf(a, "az");
190         b[0] = attrf(a, "bx");
191         b[1] = attrf(a, "by");
192         b[2] = attrf(a, "bz");
193         float taper = attrf(a, "taper", 1);
194         float mid = attrf(a, "midpoint", 0.5);
195         _airplane.addFuselage(v, b, attrf(a, "width"), taper, mid);
196     } else if(eq(name, "tank")) {
197         v[0] = attrf(a, "x");
198         v[1] = attrf(a, "y");
199         v[2] = attrf(a, "z");
200         float density = 6.0; // gasoline, in lbs/gal
201         if(a->hasAttribute("jet")) density = 6.72; 
202         density *= LBS2KG*CM2GALS;
203         _airplane.addTank(v, attrf(a, "capacity") * LBS2KG, density);
204     } else if(eq(name, "ballast")) {
205         v[0] = attrf(a, "x");
206         v[1] = attrf(a, "y");
207         v[2] = attrf(a, "z");
208         _airplane.addBallast(v, attrf(a, "mass") * LBS2KG);
209     } else if(eq(name, "weight")) {
210         parseWeight(a);
211     } else if(eq(name, "stall")) {
212         Wing* w = (Wing*)_currObj;
213         w->setStall(attrf(a, "aoa") * DEG2RAD);
214         w->setStallWidth(attrf(a, "width", 2) * DEG2RAD);
215         w->setStallPeak(attrf(a, "peak", 1.5));
216     } else if(eq(name, "flap0")) {
217         ((Wing*)_currObj)->setFlap0(attrf(a, "start"), attrf(a, "end"),
218                                     attrf(a, "lift"), attrf(a, "drag"));
219     } else if(eq(name, "flap1")) {
220         ((Wing*)_currObj)->setFlap1(attrf(a, "start"), attrf(a, "end"),
221                                     attrf(a, "lift"), attrf(a, "drag"));
222     } else if(eq(name, "slat")) {
223         ((Wing*)_currObj)->setSlat(attrf(a, "start"), attrf(a, "end"),
224                                    attrf(a, "aoa"), attrf(a, "drag"));
225     } else if(eq(name, "spoiler")) {
226         ((Wing*)_currObj)->setSpoiler(attrf(a, "start"), attrf(a, "end"),
227                                       attrf(a, "lift"), attrf(a, "drag"));
228     } else if(eq(name, "actionpt")) {
229         v[0] = attrf(a, "x");
230         v[1] = attrf(a, "y");
231         v[2] = attrf(a, "z");
232         ((Thruster*)_currObj)->setPosition(v);
233     } else if(eq(name, "dir")) {
234         v[0] = attrf(a, "x");
235         v[1] = attrf(a, "y");
236         v[2] = attrf(a, "z");
237         ((Thruster*)_currObj)->setDirection(v);
238     } else if(eq(name, "control-setting")) {
239         // A cruise or approach control setting
240         const char* axis = a->getValue("axis");
241         float value = attrf(a, "value", 0);
242         if(_cruiseCurr)
243             _airplane.addCruiseControl(parseAxis(axis), value);
244         else
245             _airplane.addApproachControl(parseAxis(axis), value);
246     } else if(eq(name, "control-input")) {
247
248         // A mapping of input property to a control
249         int axis = parseAxis(a->getValue("axis"));
250         int control = parseOutput(a->getValue("control"));
251         int opt = 0;
252         opt |= a->hasAttribute("split") ? ControlMap::OPT_SPLIT : 0;
253         opt |= a->hasAttribute("invert") ? ControlMap::OPT_INVERT : 0;
254         opt |= a->hasAttribute("square") ? ControlMap::OPT_SQUARE : 0;
255         
256         ControlMap* cm = _airplane.getControlMap();
257         if(a->hasAttribute("src0")) {
258                            cm->addMapping(axis, control, _currObj, opt,
259                            attrf(a, "src0"), attrf(a, "src1"), 
260                            attrf(a, "dst0"), attrf(a, "dst1"));
261         } else {
262             cm->addMapping(axis, control, _currObj, opt);
263         }
264     } else if(eq(name, "control-output")) {
265         // A property output for a control on the current object
266         ControlMap* cm = _airplane.getControlMap();
267         int type = parseOutput(a->getValue("control"));
268         int handle = cm->getOutputHandle(_currObj, type);
269
270         PropOut* p = new PropOut();
271         p->prop = fgGetNode(a->getValue("prop"), true);
272         p->handle = handle;
273         p->type = type;
274         p->left = !(a->hasAttribute("side") &&
275                         eq("right", a->getValue("side")));
276         p->min = attrf(a, "min", cm->rangeMin(type));
277         p->max = attrf(a, "max", cm->rangeMax(type));
278         _controlProps.add(p);
279
280     } else if(eq(name, "control-speed")) {
281         ControlMap* cm = _airplane.getControlMap();
282         int type = parseOutput(a->getValue("control"));
283         int handle = cm->getOutputHandle(_currObj, type);
284         float time = attrf(a, "transition-time", 0);
285         
286         cm->setTransitionTime(handle, time);
287     } else {
288         SG_LOG(SG_FLIGHT,SG_ALERT,"Unexpected tag '"
289                << name << "' found in YASim aircraft description");
290         exit(1);
291     }
292 }
293
294 void FGFDM::getExternalInput(float dt)
295 {
296     // The control axes
297     ControlMap* cm = _airplane.getControlMap();
298     cm->reset();
299     int i;
300     for(i=0; i<_axes.size(); i++) {
301         AxisRec* a = (AxisRec*)_axes.get(i);
302         float val = fgGetFloat(a->name, 0);
303         cm->setInput(a->handle, val);
304     }
305     cm->applyControls(dt);
306
307     // Weights
308     for(i=0; i<_weights.size(); i++) {
309         WeightRec* wr = (WeightRec*)_weights.get(i);
310         _airplane.setWeight(wr->handle, LBS2KG * fgGetFloat(wr->prop));
311     }
312 }
313
314 void FGFDM::setOutputProperties()
315 {
316     char buf[256];
317     int i;
318
319     float grossWgt = _airplane.getModel()->getBody()->getTotalMass() * KG2LBS;
320     fgSetFloat("/yasim/gross-weight-lbs", grossWgt);
321
322     ControlMap* cm = _airplane.getControlMap();
323     for(i=0; i<_controlProps.size(); i++) {
324         PropOut* p = (PropOut*)_controlProps.get(i);
325         float val = (p->left
326                      ? cm->getOutput(p->handle)
327                      : cm->getOutputR(p->handle));
328         float rmin = cm->rangeMin(p->type);
329         float rmax = cm->rangeMax(p->type);
330         float frac = (val - rmin) / (rmax - rmin);
331         val = frac*(p->max - p->min) + p->min;
332         p->prop->setFloatValue(val);
333     }
334
335     float totalFuel = 0, totalCap = 0;
336     float fuelDensity = 720; // in kg/m^3, default to gasoline: ~6 lb/gal
337     for(i=0; i<_airplane.numTanks(); i++) {
338         fuelDensity = _airplane.getFuelDensity(i);
339         sprintf(buf, "/consumables/fuel/tank[%d]/level-gal_us", i);
340         fgSetFloat(buf, CM2GALS*_airplane.getFuel(i)/fuelDensity);
341         sprintf(buf, "/consumables/fuel/tank[%d]/level-lbs", i);
342         fgSetFloat(buf, KG2LBS*_airplane.getFuel(i));
343         totalFuel += _airplane.getFuel(i);
344         totalCap += _airplane.getTankCapacity(i);
345     }
346     if(totalCap != 0) {
347         fgSetFloat("/consumables/fuel/total-fuel-lbs", KG2LBS*totalFuel);
348         fgSetFloat("/consumables/fuel/total-fuel-gals",
349                    CM2GALS*totalFuel/fuelDensity);
350         fgSetFloat("/consumables/fuel/total-fuel-norm", totalFuel/totalCap);
351     }
352
353     for(i=0; i<_thrusters.size(); i++) {
354         EngRec* er = (EngRec*)_thrusters.get(i);
355         Thruster* t = er->eng;
356
357         sprintf(buf, "%s/fuel-flow-gph", er->prefix);
358         fgSetFloat(buf, (t->getFuelFlow()/fuelDensity) * 3600 * CM2GALS);
359
360         if(t->getPropEngine()) {
361             PropEngine* p = t->getPropEngine();
362
363             sprintf(buf, "%s/rpm", er->prefix);
364             fgSetFloat(buf, p->getOmega() / RPM2RAD);
365         }
366
367         if(t->getPistonEngine()) {
368             PistonEngine* p = t->getPistonEngine();
369             
370             sprintf(buf, "%s/mp-osi", er->prefix);
371             fgSetFloat(buf, p->getMP() * (1/INHG2PA));
372
373             sprintf(buf, "%s/egt-degf", er->prefix);
374             fgSetFloat(buf, p->getEGT() * K2DEGF + 459.4);
375         }
376
377         if(t->getJet()) {
378             Jet* j = t->getJet();
379
380             sprintf(buf, "%s/n1", er->prefix);
381             fgSetFloat(buf, j->getN1());
382
383             sprintf(buf, "%s/n2", er->prefix);
384             fgSetFloat(buf, j->getN2());
385
386             sprintf(buf, "%s/epr", er->prefix);
387             fgSetFloat(buf, j->getEPR());
388
389             sprintf(buf, "%s/egt-degf", er->prefix);
390             fgSetFloat(buf, j->getEGT() * K2DEGF + 459.4);
391         }
392     }
393 }
394
395 Wing* FGFDM::parseWing(XMLAttributes* a, const char* type)
396 {
397     Wing* w = new Wing();
398
399     float defDihed = 0;
400     if(eq(type, "vstab"))
401         defDihed = 90;
402     else
403         w->setMirror(true);
404
405     float pos[3];
406     pos[0] = attrf(a, "x");
407     pos[1] = attrf(a, "y");
408     pos[2] = attrf(a, "z");
409     w->setBase(pos);
410
411     w->setLength(attrf(a, "length"));
412     w->setChord(attrf(a, "chord"));
413     w->setSweep(attrf(a, "sweep", 0) * DEG2RAD);
414     w->setTaper(attrf(a, "taper", 1));
415     w->setDihedral(attrf(a, "dihedral", defDihed) * DEG2RAD);
416     w->setCamber(attrf(a, "camber", 0));
417     w->setIncidence(attrf(a, "incidence", 0) * DEG2RAD);
418     w->setTwist(attrf(a, "twist", 0) * DEG2RAD);
419
420     // The 70% is a magic number that sorta kinda seems to match known
421     // throttle settings to approach speed.
422     w->setInducedDrag(0.7*attrf(a, "idrag", 1));
423
424     float effect = attrf(a, "effectiveness", 1);
425     w->setDragScale(w->getDragScale()*effect);
426
427     _currObj = w;
428     return w;
429 }
430
431 void FGFDM::parsePropeller(XMLAttributes* a)
432 {
433     float cg[3];
434     cg[0] = attrf(a, "x");
435     cg[1] = attrf(a, "y");
436     cg[2] = attrf(a, "z");
437     float mass = attrf(a, "mass") * LBS2KG;
438     float moment = attrf(a, "moment");
439     float radius = attrf(a, "radius");
440     float speed = attrf(a, "cruise-speed") * KTS2MPS;
441     float omega = attrf(a, "cruise-rpm") * RPM2RAD;
442     float power = attrf(a, "cruise-power") * HP2W;
443     float rho = Atmosphere::getStdDensity(attrf(a, "cruise-alt") * FT2M);
444
445     // Hack, fix this pronto:
446     float engP = attrf(a, "eng-power") * HP2W;
447     float engS = attrf(a, "eng-rpm") * RPM2RAD;
448
449     Propeller* prop = new Propeller(radius, speed, omega, rho, power);
450     PistonEngine* eng = new PistonEngine(engP, engS);
451     PropEngine* thruster = new PropEngine(prop, eng, moment);
452     _airplane.addThruster(thruster, mass, cg);
453
454     if(a->hasAttribute("displacement"))
455         eng->setDisplacement(attrf(a, "displacement") * CIN2CM);
456
457     if(a->hasAttribute("compression"))
458         eng->setCompression(attrf(a, "compression"));        
459
460     if(a->hasAttribute("turbo-mul")) {
461         float mul = attrf(a, "turbo-mul");
462         float mp = attrf(a, "wastegate-mp", 1e6) * INHG2PA;
463         eng->setTurboParams(mul, mp);
464     }
465
466     if(a->hasAttribute("takeoff-power")) {
467         float power0 = attrf(a, "takeoff-power") * HP2W;
468         float omega0 = attrf(a, "takeoff-rpm") * RPM2RAD;
469         prop->setTakeoff(omega0, power0);
470     }
471
472     if(a->hasAttribute("max-rpm")) {
473         float max = attrf(a, "max-rpm") * RPM2RAD;
474         float min = attrf(a, "min-rpm") * RPM2RAD;
475         thruster->setVariableProp(min, max);
476     }
477
478     char buf[64];
479     sprintf(buf, "/engines/engine[%d]", _nextEngine++);
480     EngRec* er = new EngRec();
481     er->eng = thruster;
482     er->prefix = dup(buf);
483     _thrusters.add(er);
484
485     _currObj = thruster;
486 }
487
488 // Turns a string axis name into an integer for use by the
489 // ControlMap.  Creates a new axis if this one hasn't been defined
490 // yet.
491 int FGFDM::parseAxis(const char* name)
492 {
493     int i;
494     for(i=0; i<_axes.size(); i++) {
495         AxisRec* a = (AxisRec*)_axes.get(i);
496         if(eq(a->name, name))
497             return a->handle;
498     }
499
500     // Not there, make a new one.
501     AxisRec* a = new AxisRec();
502     a->name = dup(name);
503     a->handle = _airplane.getControlMap()->newInput();
504     _axes.add(a);
505     return a->handle;
506 }
507
508 int FGFDM::parseOutput(const char* name)
509 {
510     if(eq(name, "THROTTLE"))  return ControlMap::THROTTLE;
511     if(eq(name, "MIXTURE"))   return ControlMap::MIXTURE;
512     if(eq(name, "STARTER"))   return ControlMap::STARTER;
513     if(eq(name, "MAGNETOS"))  return ControlMap::MAGNETOS;
514     if(eq(name, "ADVANCE"))   return ControlMap::ADVANCE;
515     if(eq(name, "REHEAT"))    return ControlMap::REHEAT;
516     if(eq(name, "BOOST"))     return ControlMap::BOOST;
517     if(eq(name, "VECTOR"))    return ControlMap::VECTOR;
518     if(eq(name, "PROP"))      return ControlMap::PROP;
519     if(eq(name, "BRAKE"))     return ControlMap::BRAKE;
520     if(eq(name, "STEER"))     return ControlMap::STEER;
521     if(eq(name, "EXTEND"))    return ControlMap::EXTEND;
522     if(eq(name, "INCIDENCE")) return ControlMap::INCIDENCE;
523     if(eq(name, "FLAP0"))     return ControlMap::FLAP0;
524     if(eq(name, "FLAP1"))     return ControlMap::FLAP1;
525     if(eq(name, "SLAT"))      return ControlMap::SLAT;
526     if(eq(name, "SPOILER"))   return ControlMap::SPOILER;
527     if(eq(name, "CASTERING")) return ControlMap::CASTERING;
528     SG_LOG(SG_FLIGHT,SG_ALERT,"Unrecognized control type '"
529            << name << "' in YASim aircraft description.");
530     exit(1);
531
532 }
533
534 void FGFDM::parseWeight(XMLAttributes* a)
535 {
536     WeightRec* wr = new WeightRec();
537
538     float v[3];
539     v[0] = attrf(a, "x");
540     v[1] = attrf(a, "y");
541     v[2] = attrf(a, "z");
542
543     wr->prop = dup(a->getValue("mass-prop"));
544     wr->size = attrf(a, "size", 0);
545     wr->handle = _airplane.addWeight(v, wr->size);
546
547     _weights.add(wr);
548 }
549
550 bool FGFDM::eq(const char* a, const char* b)
551 {
552     // Figure it out for yourself. :)
553     while(*a && *b && *a == *b) { a++; b++; }
554     return !(*a || *b);
555 }
556
557 char* FGFDM::dup(const char* s)
558 {
559     int len=0;
560     while(s[len++]);
561     char* s2 = new char[len+1];
562     char* p = s2;
563     while((*p++ = *s++));
564     s2[len] = 0;
565     return s2;
566 }
567
568 int FGFDM::attri(XMLAttributes* atts, char* attr)
569 {
570     if(!atts->hasAttribute(attr)) {
571         SG_LOG(SG_FLIGHT,SG_ALERT,"Missing '" << attr <<
572                "' in YASim aircraft description");
573         exit(1);
574     }
575     return attri(atts, attr, 0);
576 }
577
578 int FGFDM::attri(XMLAttributes* atts, char* attr, int def)
579 {
580     const char* val = atts->getValue(attr);
581     if(val == 0) return def;
582     else         return atol(val);
583 }
584
585 float FGFDM::attrf(XMLAttributes* atts, char* attr)
586 {
587     if(!atts->hasAttribute(attr)) {
588         SG_LOG(SG_FLIGHT,SG_ALERT,"Missing '" << attr <<
589                "' in YASim aircraft description");
590         exit(1);
591     }
592     return attrf(atts, attr, 0);
593 }
594
595 float FGFDM::attrf(XMLAttributes* atts, char* attr, float def)
596 {
597     const char* val = atts->getValue(attr);
598     if(val == 0) return def;
599     else         return (float)atof(val);    
600 }
601
602 }; // namespace yasim