]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/yasim-test.cpp
First cut at a turbulence model for YASim. It's a
[flightgear.git] / src / FDM / YASim / yasim-test.cpp
1 #include <stdio.h>
2
3 #include <simgear/props/props.hxx>
4 #include <simgear/xml/easyxml.hxx>
5
6 #include "FGFDM.hpp"
7 #include "Airplane.hpp"
8
9 using namespace yasim;
10
11 // Stubs.  Not needed by a batch program, but required to link.
12 bool fgSetFloat (const char * name, float val) { return false; }
13 bool fgSetBool(char const * name, bool val) { return false; }
14 bool fgGetBool(char const * name, bool def) { return false; }
15 SGPropertyNode* fgGetNode (const char * path, bool create) { return 0; }
16 float fgGetFloat (const char * name, float defaultValue) { return 0; }
17
18 static const float RAD2DEG = 57.2957795131;
19
20 int main(int argc, char** argv)
21 {
22     FGFDM fdm;
23     Airplane* a = fdm.getAirplane();
24
25     // Read
26     try {
27         readXML(argv[1], fdm);
28     } catch (const sg_exception &e) {
29         printf("XML parse error: %s (%s)\n",
30                e.getFormattedMessage().c_str(), e.getOrigin().c_str());
31     }
32
33     // ... and run
34     a->compile();
35
36     float aoa = a->getCruiseAoA() * RAD2DEG;
37     float tail = -1 * a->getTailIncidence() * RAD2DEG;
38     float drag = 1000 * a->getDragCoefficient();
39     float cg[3];
40     a->getModel()->getBody()->getCG(cg);
41
42     printf("Solution results:");
43     printf("       Iterations: %d\n", a->getSolutionIterations());
44     printf(" Drag Coefficient: %f\n", drag);
45     printf("       Lift Ratio: %f\n", a->getLiftRatio());
46     printf("       Cruise AoA: %f\n", aoa);
47     printf("   Tail Incidence: %f\n", tail);
48     printf("Approach Elevator: %f\n", a->getApproachElevator());
49     printf("               CG: %.3f, %.3f, %.3f\n", cg[0], cg[1], cg[2]);
50
51     if(a->getFailureMsg())
52         printf("SOLUTION FAILURE: %s\n", a->getFailureMsg());
53 }