]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/yasim-test.cpp
Fix coordinate conventions for reporting pilot acceleration. Add a few
[flightgear.git] / src / FDM / YASim / yasim-test.cpp
1 #include <stdio.h>
2
3 #include <simgear/xml/easyxml.hxx>
4 #include <simgear/misc/props.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 SGPropertyNode* fgGetNode (const char * path, bool create) { return 0; }
15 float fgGetFloat (const char * name, float defaultValue) { return 0; }
16
17 static const float RAD2DEG = 57.2957795131;
18
19 int main(int argc, char** argv)
20 {
21     FGFDM fdm;
22     Airplane* a = fdm.getAirplane();
23
24     // Read
25     try {
26         readXML(argv[1], fdm);
27     } catch (const sg_exception &e) {
28         printf("XML parse error: %s (%s)\n",
29                e.getFormattedMessage().c_str(), e.getOrigin().c_str());
30     }
31
32     // ... and run
33     a->compile();
34
35     float aoa = a->getCruiseAoA() * RAD2DEG;
36     float tail = -1 * a->getTailIncidence() * RAD2DEG;
37     float drag = 1000 * a->getDragCoefficient();
38     float cg[3];
39     a->getModel()->getBody()->getCG(cg);
40
41     printf("Solution results:");
42     printf("       Iterations: %d\n", a->getSolutionIterations());
43     printf(" Drag Coefficient: %f\n", drag);
44     printf("       Lift Ratio: %f\n", a->getLiftRatio());
45     printf("       Cruise AoA: %f\n", aoa);
46     printf("   Tail Incidence: %f\n", tail);
47     printf("Approach Elevator: %f\n", a->getApproachElevator());
48     printf("               CG: %.1f, %.1f, %.1f\n", cg[0], cg[1], cg[2]);
49
50     if(a->getFailureMsg())
51         printf("SOLUTION FAILURE: %s\n", a->getFailureMsg());
52 }