2002-06-10 20:15:35 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2003-05-06 23:46:24 +00:00
|
|
|
#include <simgear/props/props.hxx>
|
2002-06-10 20:15:35 +00:00
|
|
|
#include <simgear/xml/easyxml.hxx>
|
|
|
|
|
|
|
|
#include "FGFDM.hpp"
|
|
|
|
#include "Airplane.hpp"
|
|
|
|
|
|
|
|
using namespace yasim;
|
|
|
|
|
|
|
|
// Stubs. Not needed by a batch program, but required to link.
|
|
|
|
bool fgSetFloat (const char * name, float val) { return false; }
|
|
|
|
bool fgSetBool(char const * name, bool val) { return false; }
|
2002-11-30 20:22:25 +00:00
|
|
|
bool fgGetBool(char const * name, bool def) { return false; }
|
2002-06-10 20:15:35 +00:00
|
|
|
SGPropertyNode* fgGetNode (const char * path, bool create) { return 0; }
|
2004-04-30 19:06:29 +00:00
|
|
|
SGPropertyNode* fgGetNode (const char * path, int i, bool create) { return 0; }
|
2002-06-10 20:15:35 +00:00
|
|
|
float fgGetFloat (const char * name, float defaultValue) { return 0; }
|
2004-03-27 04:07:18 +00:00
|
|
|
float fgGetDouble (const char * name, double defaultValue) { return 0; }
|
|
|
|
float fgSetDouble (const char * name, double defaultValue) { return 0; }
|
2002-06-10 20:15:35 +00:00
|
|
|
|
|
|
|
static const float RAD2DEG = 57.2957795131;
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2006-03-10 22:21:42 +00:00
|
|
|
FGFDM* fdm = new FGFDM();
|
|
|
|
Airplane* a = fdm->getAirplane();
|
2002-06-10 20:15:35 +00:00
|
|
|
|
|
|
|
// Read
|
|
|
|
try {
|
2006-03-10 22:21:42 +00:00
|
|
|
string file = argv[1];
|
|
|
|
readXML(file, *fdm);
|
2002-06-10 20:15:35 +00:00
|
|
|
} catch (const sg_exception &e) {
|
|
|
|
printf("XML parse error: %s (%s)\n",
|
|
|
|
e.getFormattedMessage().c_str(), e.getOrigin().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
// ... and run
|
|
|
|
a->compile();
|
|
|
|
|
|
|
|
float aoa = a->getCruiseAoA() * RAD2DEG;
|
|
|
|
float tail = -1 * a->getTailIncidence() * RAD2DEG;
|
|
|
|
float drag = 1000 * a->getDragCoefficient();
|
|
|
|
float cg[3];
|
|
|
|
a->getModel()->getBody()->getCG(cg);
|
|
|
|
|
|
|
|
printf("Solution results:");
|
|
|
|
printf(" Iterations: %d\n", a->getSolutionIterations());
|
|
|
|
printf(" Drag Coefficient: %f\n", drag);
|
|
|
|
printf(" Lift Ratio: %f\n", a->getLiftRatio());
|
|
|
|
printf(" Cruise AoA: %f\n", aoa);
|
|
|
|
printf(" Tail Incidence: %f\n", tail);
|
|
|
|
printf("Approach Elevator: %f\n", a->getApproachElevator());
|
2002-11-30 06:28:18 +00:00
|
|
|
printf(" CG: %.3f, %.3f, %.3f\n", cg[0], cg[1], cg[2]);
|
2002-06-10 20:15:35 +00:00
|
|
|
|
|
|
|
if(a->getFailureMsg())
|
|
|
|
printf("SOLUTION FAILURE: %s\n", a->getFailureMsg());
|
2006-03-10 22:21:42 +00:00
|
|
|
|
|
|
|
delete fdm;
|
|
|
|
|
|
|
|
return 0;
|
2002-06-10 20:15:35 +00:00
|
|
|
}
|