From 96eff71a138a41069aa6b43c07f07c4822267098 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 10 Jul 2001 15:56:38 +0000 Subject: [PATCH] 20010710 sync with JSBSim. --- src/FDM/JSBSim/FGAerodynamics.cpp | 2 +- src/FDM/JSBSim/FGAerodynamics.h | 2 +- src/FDM/JSBSim/FGAircraft.cpp | 45 ++++++++++------------------ src/FDM/JSBSim/FGAircraft.h | 13 ++------ src/FDM/JSBSim/FGCoefficient.h | 27 +++++++++-------- src/FDM/JSBSim/FGFCS.cpp | 6 ++-- src/FDM/JSBSim/FGFCS.h | 6 +--- src/FDM/JSBSim/FGFDMExec.cpp | 18 +++++++++-- src/FDM/JSBSim/FGGroundReactions.cpp | 3 +- src/FDM/JSBSim/FGGroundReactions.h | 2 +- src/FDM/JSBSim/FGModel.h | 8 ++++- src/FDM/JSBSim/FGOutput.cpp | 26 +++++++++++----- src/FDM/JSBSim/FGPosition.cpp | 4 +-- src/FDM/JSBSim/FGPosition.h | 2 -- src/FDM/JSBSim/FGPropeller.cpp | 4 +-- src/FDM/JSBSim/FGPropulsion.cpp | 2 +- src/FDM/JSBSim/FGPropulsion.h | 2 +- src/FDM/JSBSim/FGTranslation.cpp | 28 +++++++++-------- src/FDM/JSBSim/FGTranslation.h | 3 ++ src/FDM/JSBSim/JSBSim.cpp | 3 +- 20 files changed, 105 insertions(+), 101 deletions(-) diff --git a/src/FDM/JSBSim/FGAerodynamics.cpp b/src/FDM/JSBSim/FGAerodynamics.cpp index 1e18f3bb7..a24df84bd 100644 --- a/src/FDM/JSBSim/FGAerodynamics.cpp +++ b/src/FDM/JSBSim/FGAerodynamics.cpp @@ -131,7 +131,7 @@ bool FGAerodynamics::Run(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -bool FGAerodynamics::LoadAerodynamics(FGConfigFile* AC_cfg) +bool FGAerodynamics::Load(FGConfigFile* AC_cfg) { string token, axis; diff --git a/src/FDM/JSBSim/FGAerodynamics.h b/src/FDM/JSBSim/FGAerodynamics.h index 5e97441c9..817e01453 100644 --- a/src/FDM/JSBSim/FGAerodynamics.h +++ b/src/FDM/JSBSim/FGAerodynamics.h @@ -105,7 +105,7 @@ public: /** Loads the Aerodynamics model @return true if successful */ - bool LoadAerodynamics(FGConfigFile* AC_cfg); + bool Load(FGConfigFile* AC_cfg); /** Outputs coefficient information. Non-dimensionalizing parameter descriptions are output diff --git a/src/FDM/JSBSim/FGAircraft.cpp b/src/FDM/JSBSim/FGAircraft.cpp index 65b863f88..bc73c5c97 100644 --- a/src/FDM/JSBSim/FGAircraft.cpp +++ b/src/FDM/JSBSim/FGAircraft.cpp @@ -28,8 +28,7 @@ FUNCTIONAL DESCRIPTION -------------------------------------------------------------------------------- Models the aircraft reactions and forces. This class is instantiated by the -FGFDMExec class and scheduled as an FDM entry. LoadAircraft() is supplied with a -name of a valid, registered aircraft, and the data file is parsed. +FGFDMExec class and scheduled as an FDM entry. HISTORY -------------------------------------------------------------------------------- @@ -190,46 +189,32 @@ FGAircraft::~FGAircraft() //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string fname) { - string path; - string filename; - string aircraftCfgFileName; +bool FGAircraft::Load(FGConfigFile* AC_cfg) +{ string token; - AircraftPath = aircraft_path; - EnginePath = engine_path; + ReadPrologue(AC_cfg); -# ifndef macintosh - aircraftCfgFileName = AircraftPath + "/" + fname + "/" + fname + ".xml"; -# else - aircraftCfgFileName = AircraftPath + ";" + fname + ";" + fname + ".xml"; -# endif - - FGConfigFile AC_cfg(aircraftCfgFileName); - if (!AC_cfg.IsOpen()) return false; - - ReadPrologue(&AC_cfg); - - while ((AC_cfg.GetNextConfigLine() != "EOF") && - (token = AC_cfg.GetValue()) != "/FDM_CONFIG") { + while ((AC_cfg->GetNextConfigLine() != "EOF") && + (token = AC_cfg->GetValue()) != "/FDM_CONFIG") { if (token == "METRICS") { if (debug_lvl > 0) cout << fgcyan << "\n Reading Metrics" << fgdef << endl; - ReadMetrics(&AC_cfg); + ReadMetrics(AC_cfg); } else if (token == "AERODYNAMICS") { if (debug_lvl > 0) cout << fgcyan << "\n Reading Aerodynamics" << fgdef << endl; - ReadAerodynamics(&AC_cfg); + ReadAerodynamics(AC_cfg); } else if (token == "UNDERCARRIAGE") { if (debug_lvl > 0) cout << fgcyan << "\n Reading Landing Gear" << fgdef << endl; - ReadUndercarriage(&AC_cfg); + ReadUndercarriage(AC_cfg); } else if (token == "PROPULSION") { if (debug_lvl > 0) cout << fgcyan << "\n Reading Propulsion" << fgdef << endl; - ReadPropulsion(&AC_cfg); + ReadPropulsion(AC_cfg); } else if (token == "FLIGHT_CONTROL") { if (debug_lvl > 0) cout << fgcyan << "\n Reading Flight Control" << fgdef << endl; - ReadFlightControls(&AC_cfg); + ReadFlightControls(AC_cfg); } else if (token == "OUTPUT") { if (debug_lvl > 0) cout << fgcyan << "\n Reading Output directives" << fgdef << endl; - ReadOutput(&AC_cfg); + ReadOutput(AC_cfg); } } @@ -375,7 +360,7 @@ void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg) { - if (!Propulsion->LoadPropulsion(AC_cfg)) { + if (!Propulsion->Load(AC_cfg)) { cerr << "Propulsion not successfully loaded" << endl; } } @@ -383,7 +368,7 @@ void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg) { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg) { - if (!FCS->LoadFCS(AC_cfg)) { + if (!FCS->Load(AC_cfg)) { cerr << "Flight Controls not successfully loaded" << endl; } } @@ -392,7 +377,7 @@ void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg) { void FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg) { - if (!Aerodynamics->LoadAerodynamics(AC_cfg)) { + if (!Aerodynamics->Load(AC_cfg)) { cerr << "Aerodynamics not successfully loaded" << endl; } diff --git a/src/FDM/JSBSim/FGAircraft.h b/src/FDM/JSBSim/FGAircraft.h index 6d252e509..213fef773 100644 --- a/src/FDM/JSBSim/FGAircraft.h +++ b/src/FDM/JSBSim/FGAircraft.h @@ -43,16 +43,13 @@ INCLUDES # ifdef SG_HAVE_STD_INCLUDES # include # include -# include # else # include # include -# include # endif #else # include # include -# include #endif #include "FGModel.h" @@ -130,11 +127,9 @@ public: /** Loads the aircraft. The executive calls this method to load the aircraft into JSBSim. - @param apath path to the aircraft files (e.g. "aircraft/X15/") - @param epath path to engine files (e.g. "engine/") - @param acname name of aircraft (e.g. "X15") - @return true if succesful */ - bool LoadAircraft(string apath, string epath, string acname); + @param AC_cfg a pointer to the config file instance + @return true if successful */ + bool Load(FGConfigFile* AC_cfg); /** Gets the aircraft name @return the name of the aircraft as a string type */ @@ -217,8 +212,6 @@ private: vector lGear; - string AircraftPath; - string EnginePath; void ReadMetrics(FGConfigFile*); void ReadPropulsion(FGConfigFile*); void ReadFlightControls(FGConfigFile*); diff --git a/src/FDM/JSBSim/FGCoefficient.h b/src/FDM/JSBSim/FGCoefficient.h index 5cd6799c3..ce236f131 100644 --- a/src/FDM/JSBSim/FGCoefficient.h +++ b/src/FDM/JSBSim/FGCoefficient.h @@ -97,7 +97,18 @@ CLASS DECLARATION class FGCoefficient { +public: + FGCoefficient(FGFDMExec*, FGConfigFile*); + ~FGCoefficient(); + typedef vector MultVec; + float TotalValue(void); + inline string Getname(void) {return name;} + inline float GetSD(void) {return SD;} + inline MultVec Getmultipliers(void) {return multipliers;} + void DumpSD(void); + +private: enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION}; int numInstances; @@ -105,6 +116,9 @@ class FGCoefficient string description; string name; string method; + float Value(float, float); + float Value(float); + float Value(void); float StaticValue; eParam LookupR, LookupC; MultVec multipliers; @@ -124,19 +138,6 @@ class FGCoefficient FGAuxiliary* Auxiliary; FGOutput* Output; -public: - FGCoefficient(FGFDMExec*, FGConfigFile*); - ~FGCoefficient(); - - float Value(float, float); - float Value(float); - float Value(void); - float TotalValue(void); - inline string Getname(void) {return name;} - inline float GetSD(void) {return SD;} - inline MultVec Getmultipliers(void) {return multipliers;} - void DumpSD(void); -private: void Debug(void); }; diff --git a/src/FDM/JSBSim/FGFCS.cpp b/src/FDM/JSBSim/FGFCS.cpp index 466e0147f..1be919c3c 100644 --- a/src/FDM/JSBSim/FGFCS.cpp +++ b/src/FDM/JSBSim/FGFCS.cpp @@ -134,12 +134,12 @@ void FGFCS::SetThrottlePos(int engineNum, float setting) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -bool FGFCS::LoadFCS(FGConfigFile* AC_cfg) +bool FGFCS::Load(FGConfigFile* AC_cfg) { string token; - FCSName = AC_cfg->GetValue("NAME"); - if (debug_lvl > 0) cout << " Control System Name: " << FCSName << endl; + Name = AC_cfg->GetValue("NAME"); + if (debug_lvl > 0) cout << " Control System Name: " << Name << endl; AC_cfg->GetNextConfigLine(); while ((token = AC_cfg->GetValue()) != "/FLIGHT_CONTROL") { if (token == "COMPONENT") { diff --git a/src/FDM/JSBSim/FGFCS.h b/src/FDM/JSBSim/FGFCS.h index 2dae2aa0d..dfaa66032 100644 --- a/src/FDM/JSBSim/FGFCS.h +++ b/src/FDM/JSBSim/FGFCS.h @@ -350,11 +350,7 @@ public: the config file instance pointer. LoadFCS() is called from FGAircraft. @param AC_cfg pointer to the config file instance @return true if succesful */ - bool LoadFCS(FGConfigFile* AC_cfg); - - /** The name of the flight control laws for this aircraft. - This is given in the config file, and is not used for anything currently.*/ - string FCSName; + bool Load(FGConfigFile* AC_cfg); void AddThrottle(void); diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp index 0e8cb976d..ed10e6986 100644 --- a/src/FDM/JSBSim/FGFDMExec.cpp +++ b/src/FDM/JSBSim/FGFDMExec.cpp @@ -364,14 +364,26 @@ bool FGFDMExec::LoadModel(string APath, string EPath, string model) { bool result = false; + string aircraftCfgFileName; + + AircraftPath = APath; + EnginePath = EPath; + +# ifndef macintosh + aircraftCfgFileName = AircraftPath + "/" + model + "/" + model + ".xml"; +# else + aircraftCfgFileName = AircraftPath + ";" + model + ";" + model + ".xml"; +# endif + + FGConfigFile AC_cfg(aircraftCfgFileName); + if (!AC_cfg.IsOpen()) return false; + if (modelLoaded) { DeAllocate(); Allocate(); } - AircraftPath = APath; - EnginePath = EPath; - result = Aircraft->LoadAircraft(AircraftPath, EnginePath, model); + result = Aircraft->Load(&AC_cfg); if (result) { modelLoaded = true; diff --git a/src/FDM/JSBSim/FGGroundReactions.cpp b/src/FDM/JSBSim/FGGroundReactions.cpp index 66ee85ef3..0d310fd9d 100644 --- a/src/FDM/JSBSim/FGGroundReactions.cpp +++ b/src/FDM/JSBSim/FGGroundReactions.cpp @@ -66,9 +66,8 @@ bool FGGroundReactions:: Run(void) { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -bool FGGroundReactions::LoadGroundReactions(FGConfigFile* AC_cfg) +bool FGGroundReactions::Load(FGConfigFile* AC_cfg) { -// return true; } diff --git a/src/FDM/JSBSim/FGGroundReactions.h b/src/FDM/JSBSim/FGGroundReactions.h index e4bc87fc6..a0b4caf0e 100644 --- a/src/FDM/JSBSim/FGGroundReactions.h +++ b/src/FDM/JSBSim/FGGroundReactions.h @@ -69,7 +69,7 @@ public: ~FGGroundReactions(); bool Run(void); - bool LoadGroundReactions(FGConfigFile* AC_cfg); + bool Load(FGConfigFile* AC_cfg); private: void Debug(void); diff --git a/src/FDM/JSBSim/FGModel.h b/src/FDM/JSBSim/FGModel.h index dcb08daca..ebf2a5108 100644 --- a/src/FDM/JSBSim/FGModel.h +++ b/src/FDM/JSBSim/FGModel.h @@ -79,6 +79,7 @@ class FGRotation; class FGPosition; class FGAuxiliary; class FGOutput; +class FGConfigFile; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs] @@ -105,10 +106,15 @@ public: /// Destructor virtual ~FGModel(); + /** Loads this model. + @param Config a pointer to the config file instance + @return true if model is successfully loaded*/ + virtual bool Load(FGConfigFile* Config) {} + FGModel* NextModel; string Name; - /** Runs the model; called by the Executive + /** Runs the model; called by the Executive @see JSBSim.cpp documentation @return false if no error */ virtual bool Run(void); diff --git a/src/FDM/JSBSim/FGOutput.cpp b/src/FDM/JSBSim/FGOutput.cpp index e03f0266e..af3b8ad22 100644 --- a/src/FDM/JSBSim/FGOutput.cpp +++ b/src/FDM/JSBSim/FGOutput.cpp @@ -158,7 +158,8 @@ void FGOutput::DelimitedOutput(void) cout << ", "; cout << "QBar, "; cout << "Vtotal, "; - cout << "U, V, W, "; + cout << "UBody, VBody, WBody, "; + cout << "UAero, VAero, WAero, "; cout << "Vn, Ve, Vd"; } if (SubSystems & FGAircraft::ssForces) { @@ -233,6 +234,7 @@ void FGOutput::DelimitedOutput(void) cout << Translation->Getqbar() << ", "; cout << Translation->GetVt() << ", "; cout << Translation->GetUVW() << ", "; + cout << Translation->GetvAero() << ", "; cout << Position->GetVel(); } if (SubSystems & FGAircraft::ssForces) { @@ -312,7 +314,8 @@ void FGOutput::DelimitedOutput(string fname) datafile << ", "; datafile << "QBar, "; datafile << "Vtotal, "; - datafile << "U, V, W, "; + datafile << "UBody, VBody, WBody, "; + datafile << "UAero, VAero, WAero, "; datafile << "Vn, Ve, Vd"; } if (SubSystems & FGAircraft::ssForces) { @@ -390,6 +393,7 @@ void FGOutput::DelimitedOutput(string fname) datafile << Translation->Getqbar() << ", "; datafile << Translation->GetVt() << ", "; datafile << Translation->GetUVW() << ", "; + datafile << Translation->GetvAero() << ", "; datafile << Position->GetVel(); } if (SubSystems & FGAircraft::ssForces) { @@ -463,9 +467,12 @@ void FGOutput::SocketOutput(void) socket->Append("Psi"); socket->Append("Rho"); socket->Append("Vtotal"); - socket->Append("U"); - socket->Append("V"); - socket->Append("W"); + socket->Append("UBody"); + socket->Append("VBody"); + socket->Append("WBody"); + socket->Append("UAero"); + socket->Append("VAero"); + socket->Append("WAero"); socket->Append("Vn"); socket->Append("Ve"); socket->Append("Vd"); @@ -504,9 +511,12 @@ void FGOutput::SocketOutput(void) socket->Append(Rotation->Getpsi()); socket->Append(Atmosphere->GetDensity()); socket->Append(Translation->GetVt()); - socket->Append(Translation->GetU()); - socket->Append(Translation->GetV()); - socket->Append(Translation->GetW()); + socket->Append(Translation->GetUVW(eU)); + socket->Append(Translation->GetUVW(eV)); + socket->Append(Translation->GetUVW(eW)); + socket->Append(Translation->GetvAero(eU)); + socket->Append(Translation->GetvAero(eV)); + socket->Append(Translation->GetvAero(eW)); socket->Append(Position->GetVn()); socket->Append(Position->GetVe()); socket->Append(Position->GetVd()); diff --git a/src/FDM/JSBSim/FGPosition.cpp b/src/FDM/JSBSim/FGPosition.cpp index e8e09b867..078f495b8 100644 --- a/src/FDM/JSBSim/FGPosition.cpp +++ b/src/FDM/JSBSim/FGPosition.cpp @@ -93,7 +93,6 @@ extern double globalSceneryAltitude; extern double globalSeaLevelRadius; FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex), - vUVW(3), vVel(3), vVelDot(3), vRunwayNormal(3) @@ -184,9 +183,8 @@ bool FGPosition:: Run(void) { void FGPosition::GetState(void) { dt = State->Getdt(); - vUVW = Translation->GetUVW(); Vt = Translation->GetVt(); - vVel = State->GetTb2l()*vUVW + Atmosphere->GetWindNED(); + vVel = State->GetTb2l() * Translation->GetUVW(); vVelDot = State->GetTb2l() * Translation->GetUVWdot(); b = Aircraft->GetWingSpan(); diff --git a/src/FDM/JSBSim/FGPosition.h b/src/FDM/JSBSim/FGPosition.h index acb7c265b..97d57d610 100644 --- a/src/FDM/JSBSim/FGPosition.h +++ b/src/FDM/JSBSim/FGPosition.h @@ -83,7 +83,6 @@ public: inline FGColumnVector GetVel(void) { return vVel; } inline FGColumnVector GetVelDot(void) { return vVelDot; } - inline FGColumnVector GetUVW(void) { return vUVW; } inline double GetVn(void) { return vVel(eX); } inline double GetVe(void) { return vVel(eY); } inline double GetVd(void) { return vVel(eZ); } @@ -115,7 +114,6 @@ public: } private: - FGColumnVector vUVW; FGColumnVector vVel; FGColumnVector vVelDot; FGColumnVector vRunwayNormal; diff --git a/src/FDM/JSBSim/FGPropeller.cpp b/src/FDM/JSBSim/FGPropeller.cpp index 650654047..b37f66bde 100644 --- a/src/FDM/JSBSim/FGPropeller.cpp +++ b/src/FDM/JSBSim/FGPropeller.cpp @@ -140,7 +140,7 @@ FGPropeller::~FGPropeller() float FGPropeller::Calculate(float PowerAvailable) { float J, C_Thrust, omega; - float Vel = (fdmex->GetTranslation()->GetUVW())(1); + float Vel = (fdmex->GetTranslation()->GetvAero())(1); float rho = fdmex->GetAtmosphere()->GetDensity(); float RPS = RPM/60.0; @@ -175,7 +175,7 @@ float FGPropeller::GetPowerRequired(void) float cPReq, RPS = RPM / 60.0; - float J = (fdmex->GetTranslation()->GetUVW())(1) / (Diameter * RPS); + float J = (fdmex->GetTranslation()->GetvAero())(1) / (Diameter * RPS); float rho = fdmex->GetAtmosphere()->GetDensity(); if (MaxPitch == MinPitch) { // Fixed pitch prop diff --git a/src/FDM/JSBSim/FGPropulsion.cpp b/src/FDM/JSBSim/FGPropulsion.cpp index f31f1ed34..d95c8971a 100644 --- a/src/FDM/JSBSim/FGPropulsion.cpp +++ b/src/FDM/JSBSim/FGPropulsion.cpp @@ -143,7 +143,7 @@ bool FGPropulsion::GetSteadyState(void) { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -bool FGPropulsion::LoadPropulsion(FGConfigFile* AC_cfg) +bool FGPropulsion::Load(FGConfigFile* AC_cfg) { string token, fullpath; string engineFileName, engType; diff --git a/src/FDM/JSBSim/FGPropulsion.h b/src/FDM/JSBSim/FGPropulsion.h index 524cfefcb..56e38c998 100644 --- a/src/FDM/JSBSim/FGPropulsion.h +++ b/src/FDM/JSBSim/FGPropulsion.h @@ -123,7 +123,7 @@ public: @param AC_cfg pointer to the config file instance that describes the aircraft being modeled. @return true if successfully loaded, otherwise false */ - bool LoadPropulsion(FGConfigFile* AC_cfg); + bool Load(FGConfigFile* AC_cfg); /// Retrieves the number of engines defined for the aircraft. inline unsigned int GetNumEngines(void) {return Engines.size();} diff --git a/src/FDM/JSBSim/FGTranslation.cpp b/src/FDM/JSBSim/FGTranslation.cpp index 40b37267b..65274d9fc 100644 --- a/src/FDM/JSBSim/FGTranslation.cpp +++ b/src/FDM/JSBSim/FGTranslation.cpp @@ -87,7 +87,8 @@ FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex), vForces(3), vEuler(3), vlastUVWdot(3), - mVel(3,3) + mVel(3,3), + vAero(3) { Name = "FGTranslation"; qbar = 0; @@ -130,28 +131,29 @@ bool FGTranslation::Run(void) { vNcg = vUVWdot*INVGRAVITY; vUVW += 0.5*dt*rate*(vlastUVWdot + vUVWdot); + vAero = vUVW + State->GetTl2b()*Atmosphere->GetWindNED(); - Vt = vUVW.Magnitude(); + Vt = vAero.Magnitude(); - if (vUVW(eW) != 0.0) - alpha = vUVW(eU)*vUVW(eU) > 0.0 ? atan2(vUVW(eW), vUVW(eU)) : 0.0; - if (vUVW(eV) != 0.0) - beta = vUVW(eU)*vUVW(eU)+vUVW(eW)*vUVW(eW) > 0.0 ? atan2(vUVW(eV), - sqrt(vUVW(eU)*vUVW(eU) + vUVW(eW)*vUVW(eW))) : 0.0; + if (vAero(eW) != 0.0) + alpha = vAero(eU)*vAero(eU) > 0.0 ? atan2(vAero(eW), vAero(eU)) : 0.0; + if (vAero(eV) != 0.0) + beta = vAero(eU)*vAero(eU)+vAero(eW)*vAero(eW) > 0.0 ? atan2(vAero(eV), + sqrt(vAero(eU)*vAero(eU) + vAero(eW)*vAero(eW))) : 0.0; // stolen, quite shamelessly, from LaRCsim - float mUW = (vUVW(eU)*vUVW(eU) + vUVW(eW)*vUVW(eW)); + float mUW = (vAero(eU)*vAero(eU) + vAero(eW)*vAero(eW)); float signU=1; - if (vUVW(eU) != 0.0) - signU = vUVW(eU)/fabs(vUVW(eU)); + if (vAero(eU) != 0.0) + signU = vAero(eU)/fabs(vAero(eU)); if ( (mUW == 0.0) || (Vt == 0.0) ) { adot = 0.0; bdot = 0.0; } else { - adot = (vUVW(eU)*vUVWdot(eW) - vUVW(eW)*vUVWdot(eU))/mUW; - bdot = (signU*mUW*vUVWdot(eV) - vUVW(eV)*(vUVW(eU)*vUVWdot(eU) - + vUVW(eW)*vUVWdot(eW)))/(Vt*Vt*sqrt(mUW)); + adot = (vAero(eU)*vAero(eW) - vAero(eW)*vUVWdot(eU))/mUW; + bdot = (signU*mUW*vUVWdot(eV) - vAero(eV)*(vAero(eU)*vUVWdot(eU) + + vAero(eW)*vUVWdot(eW)))/(Vt*Vt*sqrt(mUW)); } qbar = 0.5*rho*Vt*Vt; diff --git a/src/FDM/JSBSim/FGTranslation.h b/src/FDM/JSBSim/FGTranslation.h index 08e85453e..1729a9d85 100644 --- a/src/FDM/JSBSim/FGTranslation.h +++ b/src/FDM/JSBSim/FGTranslation.h @@ -87,6 +87,8 @@ public: inline float GetUVWdot(int idx) { return vUVWdot(idx); } inline FGColumnVector GetNcg (void) { return vNcg; } inline float GetNcg (int idx) { return vNcg(idx); } + inline FGColumnVector GetvAero (void) { return vAero; } + inline float GetvAero (int idx) { return vAero(idx); } inline float Getalpha(void) { return alpha; } inline float Getbeta (void) { return beta; } @@ -121,6 +123,7 @@ private: FGColumnVector vEuler; FGColumnVector vlastUVWdot; FGMatrix mVel; + FGColumnVector vAero; float Vt, qbar, Mach; float Mass, dt; diff --git a/src/FDM/JSBSim/JSBSim.cpp b/src/FDM/JSBSim/JSBSim.cpp index 400b6088b..3760784ce 100644 --- a/src/FDM/JSBSim/JSBSim.cpp +++ b/src/FDM/JSBSim/JSBSim.cpp @@ -88,7 +88,7 @@ USEUNIT("FGNozzle.cpp"); USEUNIT("FGOutput.cpp"); USEUNIT("FGPiston.cpp"); USEUNIT("FGPosition.cpp"); -USEUNIT("FGPropeller.cpp"); +USEUNIT("FGJSBBase.cpp"); USEUNIT("FGPropulsion.cpp"); USEUNIT("FGRocket.cpp"); USEUNIT("FGRotation.cpp"); @@ -112,6 +112,7 @@ USEUNIT("filtersjb\FGGain.cpp"); USEUNIT("filtersjb\FGGradient.cpp"); USEUNIT("filtersjb\FGSummer.cpp"); USEUNIT("filtersjb\FGDeadBand.cpp"); +USEUNIT("FGPropeller.cpp"); //--------------------------------------------------------------------------- #endif