From 871e4e8319596893fb0acdc5a5f733694b4dc7c6 Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 30 Dec 1999 17:42:24 +0000 Subject: [PATCH] Updates to help work the kinks out of JSBsim. --- src/FDM/JSBSim/FGAircraft.cpp | 25 +++++++++++++++++++------ src/FDM/JSBSim/FGAircraft.h | 3 ++- src/FDM/JSBSim/FGDefs.h | 1 + src/FDM/JSBSim/FGOutput.cpp | 28 ++++++++++++++++++++++------ src/Main/options.cxx | 12 ++++++------ 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/src/FDM/JSBSim/FGAircraft.cpp b/src/FDM/JSBSim/FGAircraft.cpp index 43e9a4b26..f49e9dd98 100644 --- a/src/FDM/JSBSim/FGAircraft.cpp +++ b/src/FDM/JSBSim/FGAircraft.cpp @@ -177,7 +177,14 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f #else if (holding_string.compare("//",0,2) != 0) { #endif - if (holding_string == "AIRCRAFT") { + if (holding_string == "CFG_VERSION") { + aircraftfile >> CFGVersion; + cout << "Config file version: " << CFGVersion << endl; + if (CFGVersion < NEEDED_CFG_VERSION) { + cout << endl << "YOU HAVE AN OLD CFG FILE FOR THIS AIRCRAFT." + " RESULTS WILL BE UNPREDICTABLE !!" << endl << endl; + } + } else if (holding_string == "AIRCRAFT") { cout << "Reading in Aircraft parameters ..." << endl; } else if (holding_string == "AERODYNAMICS") { cout << "Reading in Aerodynamic parameters ..." << endl; @@ -451,13 +458,19 @@ void FGAircraft::FMAero(void) - F[SideCoeff]*sin(alpha)*sin(beta) - F[LiftCoeff]*cos(alpha); - dxcg = (Xcg - Xrp)/12; //cg and rp values are in inches - dycg = (Ycg - Yrp)/12; - dzcg = (Zcg - Zrp)/12; + // The d*cg distances below, given in inches, are the distances FROM the c.g. + // TO the reference point. Since the c.g. and ref point are given in inches in + // the structural system (X positive rearwards) and the body coordinate system + // is given with X positive out the nose, the dxcg and dzcg values are + // *rotated* 180 degrees about the Y axis. - Moments[0] += -Fzaero*dycg - Fyaero*dzcg; //rolling moment + dxcg = -(Xrp - Xcg)/12; //cg and rp values are in inches + dycg = (Yrp - Ycg)/12; + dzcg = -(Zrp - Zcg)/12; + + Moments[0] += Fzaero*dycg - Fyaero*dzcg; //rolling moment Moments[1] += Fxaero*dzcg - Fzaero*dxcg; //pitching moment - Moments[2] += Fxaero*dycg + Fyaero*dxcg; //yawing moment + Moments[2] += -Fxaero*dycg + Fyaero*dxcg; //yawing moment for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) { for (ctr = 0; ctr < coeff_ctr[axis_ctr+3]; ctr++) { diff --git a/src/FDM/JSBSim/FGAircraft.h b/src/FDM/JSBSim/FGAircraft.h index 93180d633..c95762389 100644 --- a/src/FDM/JSBSim/FGAircraft.h +++ b/src/FDM/JSBSim/FGAircraft.h @@ -179,7 +179,8 @@ private: float phi, tht, psi; float Weight, EmptyWeight; float dt; - + float CFGVersion; + int numTanks; int numEngines; int numSelectedOxiTanks; diff --git a/src/FDM/JSBSim/FGDefs.h b/src/FDM/JSBSim/FGDefs.h index 28072e4f3..0447675f4 100644 --- a/src/FDM/JSBSim/FGDefs.h +++ b/src/FDM/JSBSim/FGDefs.h @@ -52,6 +52,7 @@ SENTRY #define DEGTORAD 1.745329E-2 #define KTSTOFPS 1.68781 #define FPSTOKTS 0.592484 +#define NEEDED_CFG_VERSION 1.10 #define HPTOFTLBSSEC 550 diff --git a/src/FDM/JSBSim/FGOutput.cpp b/src/FDM/JSBSim/FGOutput.cpp index 25481c1f7..014a8de05 100644 --- a/src/FDM/JSBSim/FGOutput.cpp +++ b/src/FDM/JSBSim/FGOutput.cpp @@ -74,8 +74,8 @@ FGOutput::~FGOutput(void) bool FGOutput::Run(void) { if (!FGModel::Run()) { - SocketOutput(); -// DelimitedOutput("JSBSimData.csv"); +// SocketOutput(); + DelimitedOutput("JSBSimData.csv"); } else { } return false; @@ -116,7 +116,11 @@ void FGOutput::DelimitedOutput(void) cout << "Alpha,"; cout << "L,"; cout << "M,"; - cout << "N"; + cout << "N,"; + cout << "Throttle,"; + cout << "Aileron,"; + cout << "Elevator,"; + cout << "Rudder"; cout << endl; dFirstPass = false; } @@ -152,7 +156,11 @@ void FGOutput::DelimitedOutput(void) cout << Translation->Getalpha() << ","; cout << Aircraft->GetL() << ","; cout << Aircraft->GetM() << ","; - cout << Aircraft->GetN() << ""; + cout << Aircraft->GetN() << ","; + cout << FCS->GetThrottle(0) << ","; + cout << FCS->GetDa() << ","; + cout << FCS->GetDe() << ","; + cout << FCS->GetDr() << ""; cout << endl; } @@ -193,7 +201,11 @@ void FGOutput::DelimitedOutput(string fname) datafile << "Alpha,"; datafile << "L,"; datafile << "M,"; - datafile << "N"; + datafile << "N,"; + datafile << "Throttle,"; + datafile << "Aileron,"; + datafile << "Elevator,"; + datafile << "Rudder"; datafile << endl; sFirstPass = false; } @@ -229,7 +241,11 @@ void FGOutput::DelimitedOutput(string fname) datafile << Translation->Getalpha() << ","; datafile << Aircraft->GetL() << ","; datafile << Aircraft->GetM() << ","; - datafile << Aircraft->GetN() << ""; + datafile << Aircraft->GetN() << ","; + datafile << FCS->GetThrottle(0) << ","; + datafile << FCS->GetDa() << ","; + datafile << FCS->GetDe() << ","; + datafile << FCS->GetDr() << ""; datafile << endl; datafile.flush(); } diff --git a/src/Main/options.cxx b/src/Main/options.cxx index d2273470a..6cd82a8c7 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -625,21 +625,21 @@ int fgOPTIONS::parse_option( const string& arg ) { } } else if ( arg.find( "--uBody=" ) != string::npos ) { if ( units == FG_UNITS_FEET ) { - uBody = atof( arg.substr(8) ) * FEET_TO_METER; - } else { uBody = atof( arg.substr(8) ); + } else { + uBody = atof( arg.substr(8) ) * FEET_TO_METER; } } else if ( arg.find( "--vBody=" ) != string::npos ) { if ( units == FG_UNITS_FEET ) { - vBody = atof( arg.substr(8) ) * FEET_TO_METER; - } else { vBody = atof( arg.substr(8) ); + } else { + vBody = atof( arg.substr(8) ) * FEET_TO_METER; } } else if ( arg.find( "--wBody=" ) != string::npos ) { if ( units == FG_UNITS_FEET ) { - wBody = atof( arg.substr(8) ) * FEET_TO_METER; - } else { wBody = atof( arg.substr(8) ); + } else { + wBody = atof( arg.substr(8) ) * FEET_TO_METER; } } else if ( arg.find( "--heading=" ) != string::npos ) { heading = atof( arg.substr(10) );