1
0
Fork 0

20010710 sync with JSBSim.

This commit is contained in:
curt 2001-07-10 15:56:38 +00:00
parent 968b9fcb9c
commit 96eff71a13
20 changed files with 105 additions and 101 deletions

View file

@ -131,7 +131,7 @@ bool FGAerodynamics::Run(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGAerodynamics::LoadAerodynamics(FGConfigFile* AC_cfg) bool FGAerodynamics::Load(FGConfigFile* AC_cfg)
{ {
string token, axis; string token, axis;

View file

@ -105,7 +105,7 @@ public:
/** Loads the Aerodynamics model /** Loads the Aerodynamics model
@return true if successful */ @return true if successful */
bool LoadAerodynamics(FGConfigFile* AC_cfg); bool Load(FGConfigFile* AC_cfg);
/** Outputs coefficient information. /** Outputs coefficient information.
Non-dimensionalizing parameter descriptions are output Non-dimensionalizing parameter descriptions are output

View file

@ -28,8 +28,7 @@
FUNCTIONAL DESCRIPTION FUNCTIONAL DESCRIPTION
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Models the aircraft reactions and forces. This class is instantiated by the 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 FGFDMExec class and scheduled as an FDM entry.
name of a valid, registered aircraft, and the data file is parsed.
HISTORY HISTORY
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -190,46 +189,32 @@ FGAircraft::~FGAircraft()
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string fname) { bool FGAircraft::Load(FGConfigFile* AC_cfg)
string path; {
string filename;
string aircraftCfgFileName;
string token; string token;
AircraftPath = aircraft_path; ReadPrologue(AC_cfg);
EnginePath = engine_path;
# ifndef macintosh while ((AC_cfg->GetNextConfigLine() != "EOF") &&
aircraftCfgFileName = AircraftPath + "/" + fname + "/" + fname + ".xml"; (token = AC_cfg->GetValue()) != "/FDM_CONFIG") {
# 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") {
if (token == "METRICS") { if (token == "METRICS") {
if (debug_lvl > 0) cout << fgcyan << "\n Reading Metrics" << fgdef << endl; if (debug_lvl > 0) cout << fgcyan << "\n Reading Metrics" << fgdef << endl;
ReadMetrics(&AC_cfg); ReadMetrics(AC_cfg);
} else if (token == "AERODYNAMICS") { } else if (token == "AERODYNAMICS") {
if (debug_lvl > 0) cout << fgcyan << "\n Reading Aerodynamics" << fgdef << endl; if (debug_lvl > 0) cout << fgcyan << "\n Reading Aerodynamics" << fgdef << endl;
ReadAerodynamics(&AC_cfg); ReadAerodynamics(AC_cfg);
} else if (token == "UNDERCARRIAGE") { } else if (token == "UNDERCARRIAGE") {
if (debug_lvl > 0) cout << fgcyan << "\n Reading Landing Gear" << fgdef << endl; if (debug_lvl > 0) cout << fgcyan << "\n Reading Landing Gear" << fgdef << endl;
ReadUndercarriage(&AC_cfg); ReadUndercarriage(AC_cfg);
} else if (token == "PROPULSION") { } else if (token == "PROPULSION") {
if (debug_lvl > 0) cout << fgcyan << "\n Reading Propulsion" << fgdef << endl; if (debug_lvl > 0) cout << fgcyan << "\n Reading Propulsion" << fgdef << endl;
ReadPropulsion(&AC_cfg); ReadPropulsion(AC_cfg);
} else if (token == "FLIGHT_CONTROL") { } else if (token == "FLIGHT_CONTROL") {
if (debug_lvl > 0) cout << fgcyan << "\n Reading Flight Control" << fgdef << endl; if (debug_lvl > 0) cout << fgcyan << "\n Reading Flight Control" << fgdef << endl;
ReadFlightControls(&AC_cfg); ReadFlightControls(AC_cfg);
} else if (token == "OUTPUT") { } else if (token == "OUTPUT") {
if (debug_lvl > 0) cout << fgcyan << "\n Reading Output directives" << fgdef << endl; 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) { void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg) {
if (!Propulsion->LoadPropulsion(AC_cfg)) { if (!Propulsion->Load(AC_cfg)) {
cerr << "Propulsion not successfully loaded" << endl; cerr << "Propulsion not successfully loaded" << endl;
} }
} }
@ -383,7 +368,7 @@ void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGAircraft::ReadFlightControls(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; cerr << "Flight Controls not successfully loaded" << endl;
} }
} }
@ -392,7 +377,7 @@ void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg) {
void FGAircraft::ReadAerodynamics(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; cerr << "Aerodynamics not successfully loaded" << endl;
} }

View file

@ -43,16 +43,13 @@ INCLUDES
# ifdef SG_HAVE_STD_INCLUDES # ifdef SG_HAVE_STD_INCLUDES
# include <vector> # include <vector>
# include <iterator> # include <iterator>
# include <map>
# else # else
# include <vector.h> # include <vector.h>
# include <iterator.h> # include <iterator.h>
# include <map.h>
# endif # endif
#else #else
# include <vector> # include <vector>
# include <iterator> # include <iterator>
# include <map>
#endif #endif
#include "FGModel.h" #include "FGModel.h"
@ -130,11 +127,9 @@ public:
/** Loads the aircraft. /** Loads the aircraft.
The executive calls this method to load the aircraft into JSBSim. The executive calls this method to load the aircraft into JSBSim.
@param apath path to the aircraft files (e.g. "aircraft/X15/") @param AC_cfg a pointer to the config file instance
@param epath path to engine files (e.g. "engine/") @return true if successful */
@param acname name of aircraft (e.g. "X15") bool Load(FGConfigFile* AC_cfg);
@return true if succesful */
bool LoadAircraft(string apath, string epath, string acname);
/** Gets the aircraft name /** Gets the aircraft name
@return the name of the aircraft as a string type */ @return the name of the aircraft as a string type */
@ -217,8 +212,6 @@ private:
vector <FGLGear> lGear; vector <FGLGear> lGear;
string AircraftPath;
string EnginePath;
void ReadMetrics(FGConfigFile*); void ReadMetrics(FGConfigFile*);
void ReadPropulsion(FGConfigFile*); void ReadPropulsion(FGConfigFile*);
void ReadFlightControls(FGConfigFile*); void ReadFlightControls(FGConfigFile*);

View file

@ -97,7 +97,18 @@ CLASS DECLARATION
class FGCoefficient class FGCoefficient
{ {
public:
FGCoefficient(FGFDMExec*, FGConfigFile*);
~FGCoefficient();
typedef vector <eParam> MultVec; typedef vector <eParam> 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}; enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
int numInstances; int numInstances;
@ -105,6 +116,9 @@ class FGCoefficient
string description; string description;
string name; string name;
string method; string method;
float Value(float, float);
float Value(float);
float Value(void);
float StaticValue; float StaticValue;
eParam LookupR, LookupC; eParam LookupR, LookupC;
MultVec multipliers; MultVec multipliers;
@ -124,19 +138,6 @@ class FGCoefficient
FGAuxiliary* Auxiliary; FGAuxiliary* Auxiliary;
FGOutput* Output; 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); void Debug(void);
}; };

View file

@ -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; string token;
FCSName = AC_cfg->GetValue("NAME"); Name = AC_cfg->GetValue("NAME");
if (debug_lvl > 0) cout << " Control System Name: " << FCSName << endl; if (debug_lvl > 0) cout << " Control System Name: " << Name << endl;
AC_cfg->GetNextConfigLine(); AC_cfg->GetNextConfigLine();
while ((token = AC_cfg->GetValue()) != "/FLIGHT_CONTROL") { while ((token = AC_cfg->GetValue()) != "/FLIGHT_CONTROL") {
if (token == "COMPONENT") { if (token == "COMPONENT") {

View file

@ -350,11 +350,7 @@ public:
the config file instance pointer. LoadFCS() is called from FGAircraft. the config file instance pointer. LoadFCS() is called from FGAircraft.
@param AC_cfg pointer to the config file instance @param AC_cfg pointer to the config file instance
@return true if succesful */ @return true if succesful */
bool LoadFCS(FGConfigFile* AC_cfg); bool Load(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;
void AddThrottle(void); void AddThrottle(void);

View file

@ -364,14 +364,26 @@ bool FGFDMExec::LoadModel(string APath, string EPath, string model)
{ {
bool result = false; 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) { if (modelLoaded) {
DeAllocate(); DeAllocate();
Allocate(); Allocate();
} }
AircraftPath = APath; result = Aircraft->Load(&AC_cfg);
EnginePath = EPath;
result = Aircraft->LoadAircraft(AircraftPath, EnginePath, model);
if (result) { if (result) {
modelLoaded = true; modelLoaded = true;

View file

@ -66,9 +66,8 @@ bool FGGroundReactions:: Run(void) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGGroundReactions::LoadGroundReactions(FGConfigFile* AC_cfg) bool FGGroundReactions::Load(FGConfigFile* AC_cfg)
{ {
//
return true; return true;
} }

View file

@ -69,7 +69,7 @@ public:
~FGGroundReactions(); ~FGGroundReactions();
bool Run(void); bool Run(void);
bool LoadGroundReactions(FGConfigFile* AC_cfg); bool Load(FGConfigFile* AC_cfg);
private: private:
void Debug(void); void Debug(void);

View file

@ -79,6 +79,7 @@ class FGRotation;
class FGPosition; class FGPosition;
class FGAuxiliary; class FGAuxiliary;
class FGOutput; class FGOutput;
class FGConfigFile;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs] COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
@ -105,10 +106,15 @@ public:
/// Destructor /// Destructor
virtual ~FGModel(); 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; FGModel* NextModel;
string Name; string Name;
/** Runs the model; called by the Executive /** Runs the model; called by the Executive
@see JSBSim.cpp documentation @see JSBSim.cpp documentation
@return false if no error */ @return false if no error */
virtual bool Run(void); virtual bool Run(void);

View file

@ -158,7 +158,8 @@ void FGOutput::DelimitedOutput(void)
cout << ", "; cout << ", ";
cout << "QBar, "; cout << "QBar, ";
cout << "Vtotal, "; cout << "Vtotal, ";
cout << "U, V, W, "; cout << "UBody, VBody, WBody, ";
cout << "UAero, VAero, WAero, ";
cout << "Vn, Ve, Vd"; cout << "Vn, Ve, Vd";
} }
if (SubSystems & FGAircraft::ssForces) { if (SubSystems & FGAircraft::ssForces) {
@ -233,6 +234,7 @@ void FGOutput::DelimitedOutput(void)
cout << Translation->Getqbar() << ", "; cout << Translation->Getqbar() << ", ";
cout << Translation->GetVt() << ", "; cout << Translation->GetVt() << ", ";
cout << Translation->GetUVW() << ", "; cout << Translation->GetUVW() << ", ";
cout << Translation->GetvAero() << ", ";
cout << Position->GetVel(); cout << Position->GetVel();
} }
if (SubSystems & FGAircraft::ssForces) { if (SubSystems & FGAircraft::ssForces) {
@ -312,7 +314,8 @@ void FGOutput::DelimitedOutput(string fname)
datafile << ", "; datafile << ", ";
datafile << "QBar, "; datafile << "QBar, ";
datafile << "Vtotal, "; datafile << "Vtotal, ";
datafile << "U, V, W, "; datafile << "UBody, VBody, WBody, ";
datafile << "UAero, VAero, WAero, ";
datafile << "Vn, Ve, Vd"; datafile << "Vn, Ve, Vd";
} }
if (SubSystems & FGAircraft::ssForces) { if (SubSystems & FGAircraft::ssForces) {
@ -390,6 +393,7 @@ void FGOutput::DelimitedOutput(string fname)
datafile << Translation->Getqbar() << ", "; datafile << Translation->Getqbar() << ", ";
datafile << Translation->GetVt() << ", "; datafile << Translation->GetVt() << ", ";
datafile << Translation->GetUVW() << ", "; datafile << Translation->GetUVW() << ", ";
datafile << Translation->GetvAero() << ", ";
datafile << Position->GetVel(); datafile << Position->GetVel();
} }
if (SubSystems & FGAircraft::ssForces) { if (SubSystems & FGAircraft::ssForces) {
@ -463,9 +467,12 @@ void FGOutput::SocketOutput(void)
socket->Append("Psi"); socket->Append("Psi");
socket->Append("Rho"); socket->Append("Rho");
socket->Append("Vtotal"); socket->Append("Vtotal");
socket->Append("U"); socket->Append("UBody");
socket->Append("V"); socket->Append("VBody");
socket->Append("W"); socket->Append("WBody");
socket->Append("UAero");
socket->Append("VAero");
socket->Append("WAero");
socket->Append("Vn"); socket->Append("Vn");
socket->Append("Ve"); socket->Append("Ve");
socket->Append("Vd"); socket->Append("Vd");
@ -504,9 +511,12 @@ void FGOutput::SocketOutput(void)
socket->Append(Rotation->Getpsi()); socket->Append(Rotation->Getpsi());
socket->Append(Atmosphere->GetDensity()); socket->Append(Atmosphere->GetDensity());
socket->Append(Translation->GetVt()); socket->Append(Translation->GetVt());
socket->Append(Translation->GetU()); socket->Append(Translation->GetUVW(eU));
socket->Append(Translation->GetV()); socket->Append(Translation->GetUVW(eV));
socket->Append(Translation->GetW()); 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->GetVn());
socket->Append(Position->GetVe()); socket->Append(Position->GetVe());
socket->Append(Position->GetVd()); socket->Append(Position->GetVd());

View file

@ -93,7 +93,6 @@ extern double globalSceneryAltitude;
extern double globalSeaLevelRadius; extern double globalSeaLevelRadius;
FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex), FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex),
vUVW(3),
vVel(3), vVel(3),
vVelDot(3), vVelDot(3),
vRunwayNormal(3) vRunwayNormal(3)
@ -184,9 +183,8 @@ bool FGPosition:: Run(void) {
void FGPosition::GetState(void) { void FGPosition::GetState(void) {
dt = State->Getdt(); dt = State->Getdt();
vUVW = Translation->GetUVW();
Vt = Translation->GetVt(); Vt = Translation->GetVt();
vVel = State->GetTb2l()*vUVW + Atmosphere->GetWindNED(); vVel = State->GetTb2l() * Translation->GetUVW();
vVelDot = State->GetTb2l() * Translation->GetUVWdot(); vVelDot = State->GetTb2l() * Translation->GetUVWdot();
b = Aircraft->GetWingSpan(); b = Aircraft->GetWingSpan();

View file

@ -83,7 +83,6 @@ public:
inline FGColumnVector GetVel(void) { return vVel; } inline FGColumnVector GetVel(void) { return vVel; }
inline FGColumnVector GetVelDot(void) { return vVelDot; } inline FGColumnVector GetVelDot(void) { return vVelDot; }
inline FGColumnVector GetUVW(void) { return vUVW; }
inline double GetVn(void) { return vVel(eX); } inline double GetVn(void) { return vVel(eX); }
inline double GetVe(void) { return vVel(eY); } inline double GetVe(void) { return vVel(eY); }
inline double GetVd(void) { return vVel(eZ); } inline double GetVd(void) { return vVel(eZ); }
@ -115,7 +114,6 @@ public:
} }
private: private:
FGColumnVector vUVW;
FGColumnVector vVel; FGColumnVector vVel;
FGColumnVector vVelDot; FGColumnVector vVelDot;
FGColumnVector vRunwayNormal; FGColumnVector vRunwayNormal;

View file

@ -140,7 +140,7 @@ FGPropeller::~FGPropeller()
float FGPropeller::Calculate(float PowerAvailable) float FGPropeller::Calculate(float PowerAvailable)
{ {
float J, C_Thrust, omega; float J, C_Thrust, omega;
float Vel = (fdmex->GetTranslation()->GetUVW())(1); float Vel = (fdmex->GetTranslation()->GetvAero())(1);
float rho = fdmex->GetAtmosphere()->GetDensity(); float rho = fdmex->GetAtmosphere()->GetDensity();
float RPS = RPM/60.0; float RPS = RPM/60.0;
@ -175,7 +175,7 @@ float FGPropeller::GetPowerRequired(void)
float cPReq, RPS = RPM / 60.0; 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(); float rho = fdmex->GetAtmosphere()->GetDensity();
if (MaxPitch == MinPitch) { // Fixed pitch prop if (MaxPitch == MinPitch) { // Fixed pitch prop

View file

@ -143,7 +143,7 @@ bool FGPropulsion::GetSteadyState(void) {
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGPropulsion::LoadPropulsion(FGConfigFile* AC_cfg) bool FGPropulsion::Load(FGConfigFile* AC_cfg)
{ {
string token, fullpath; string token, fullpath;
string engineFileName, engType; string engineFileName, engType;

View file

@ -123,7 +123,7 @@ public:
@param AC_cfg pointer to the config file instance that describes the @param AC_cfg pointer to the config file instance that describes the
aircraft being modeled. aircraft being modeled.
@return true if successfully loaded, otherwise false */ @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. /// Retrieves the number of engines defined for the aircraft.
inline unsigned int GetNumEngines(void) {return Engines.size();} inline unsigned int GetNumEngines(void) {return Engines.size();}

View file

@ -87,7 +87,8 @@ FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex),
vForces(3), vForces(3),
vEuler(3), vEuler(3),
vlastUVWdot(3), vlastUVWdot(3),
mVel(3,3) mVel(3,3),
vAero(3)
{ {
Name = "FGTranslation"; Name = "FGTranslation";
qbar = 0; qbar = 0;
@ -130,28 +131,29 @@ bool FGTranslation::Run(void) {
vNcg = vUVWdot*INVGRAVITY; vNcg = vUVWdot*INVGRAVITY;
vUVW += 0.5*dt*rate*(vlastUVWdot + vUVWdot); vUVW += 0.5*dt*rate*(vlastUVWdot + vUVWdot);
vAero = vUVW + State->GetTl2b()*Atmosphere->GetWindNED();
Vt = vUVW.Magnitude(); Vt = vAero.Magnitude();
if (vUVW(eW) != 0.0) if (vAero(eW) != 0.0)
alpha = vUVW(eU)*vUVW(eU) > 0.0 ? atan2(vUVW(eW), vUVW(eU)) : 0.0; alpha = vAero(eU)*vAero(eU) > 0.0 ? atan2(vAero(eW), vAero(eU)) : 0.0;
if (vUVW(eV) != 0.0) if (vAero(eV) != 0.0)
beta = vUVW(eU)*vUVW(eU)+vUVW(eW)*vUVW(eW) > 0.0 ? atan2(vUVW(eV), beta = vAero(eU)*vAero(eU)+vAero(eW)*vAero(eW) > 0.0 ? atan2(vAero(eV),
sqrt(vUVW(eU)*vUVW(eU) + vUVW(eW)*vUVW(eW))) : 0.0; sqrt(vAero(eU)*vAero(eU) + vAero(eW)*vAero(eW))) : 0.0;
// stolen, quite shamelessly, from LaRCsim // 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; float signU=1;
if (vUVW(eU) != 0.0) if (vAero(eU) != 0.0)
signU = vUVW(eU)/fabs(vUVW(eU)); signU = vAero(eU)/fabs(vAero(eU));
if ( (mUW == 0.0) || (Vt == 0.0) ) { if ( (mUW == 0.0) || (Vt == 0.0) ) {
adot = 0.0; adot = 0.0;
bdot = 0.0; bdot = 0.0;
} else { } else {
adot = (vUVW(eU)*vUVWdot(eW) - vUVW(eW)*vUVWdot(eU))/mUW; adot = (vAero(eU)*vAero(eW) - vAero(eW)*vUVWdot(eU))/mUW;
bdot = (signU*mUW*vUVWdot(eV) - vUVW(eV)*(vUVW(eU)*vUVWdot(eU) bdot = (signU*mUW*vUVWdot(eV) - vAero(eV)*(vAero(eU)*vUVWdot(eU)
+ vUVW(eW)*vUVWdot(eW)))/(Vt*Vt*sqrt(mUW)); + vAero(eW)*vUVWdot(eW)))/(Vt*Vt*sqrt(mUW));
} }
qbar = 0.5*rho*Vt*Vt; qbar = 0.5*rho*Vt*Vt;

View file

@ -87,6 +87,8 @@ public:
inline float GetUVWdot(int idx) { return vUVWdot(idx); } inline float GetUVWdot(int idx) { return vUVWdot(idx); }
inline FGColumnVector GetNcg (void) { return vNcg; } inline FGColumnVector GetNcg (void) { return vNcg; }
inline float GetNcg (int idx) { return vNcg(idx); } 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 Getalpha(void) { return alpha; }
inline float Getbeta (void) { return beta; } inline float Getbeta (void) { return beta; }
@ -121,6 +123,7 @@ private:
FGColumnVector vEuler; FGColumnVector vEuler;
FGColumnVector vlastUVWdot; FGColumnVector vlastUVWdot;
FGMatrix mVel; FGMatrix mVel;
FGColumnVector vAero;
float Vt, qbar, Mach; float Vt, qbar, Mach;
float Mass, dt; float Mass, dt;

View file

@ -88,7 +88,7 @@ USEUNIT("FGNozzle.cpp");
USEUNIT("FGOutput.cpp"); USEUNIT("FGOutput.cpp");
USEUNIT("FGPiston.cpp"); USEUNIT("FGPiston.cpp");
USEUNIT("FGPosition.cpp"); USEUNIT("FGPosition.cpp");
USEUNIT("FGPropeller.cpp"); USEUNIT("FGJSBBase.cpp");
USEUNIT("FGPropulsion.cpp"); USEUNIT("FGPropulsion.cpp");
USEUNIT("FGRocket.cpp"); USEUNIT("FGRocket.cpp");
USEUNIT("FGRotation.cpp"); USEUNIT("FGRotation.cpp");
@ -112,6 +112,7 @@ USEUNIT("filtersjb\FGGain.cpp");
USEUNIT("filtersjb\FGGradient.cpp"); USEUNIT("filtersjb\FGGradient.cpp");
USEUNIT("filtersjb\FGSummer.cpp"); USEUNIT("filtersjb\FGSummer.cpp");
USEUNIT("filtersjb\FGDeadBand.cpp"); USEUNIT("filtersjb\FGDeadBand.cpp");
USEUNIT("FGPropeller.cpp");
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#endif #endif