//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGAerodynamics::LoadAerodynamics(FGConfigFile* AC_cfg)
+bool FGAerodynamics::Load(FGConfigFile* AC_cfg)
{
string token, axis;
/** 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
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
--------------------------------------------------------------------------------
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-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;
-
-# 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);
+ 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);
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg) {
- if (!Propulsion->LoadPropulsion(AC_cfg)) {
+ if (!Propulsion->Load(AC_cfg)) {
cerr << "Propulsion not successfully loaded" << endl;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg) {
- if (!FCS->LoadFCS(AC_cfg)) {
+ if (!FCS->Load(AC_cfg)) {
cerr << "Flight Controls not successfully loaded" << endl;
}
}
void FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg)
{
- if (!Aerodynamics->LoadAerodynamics(AC_cfg)) {
+ if (!Aerodynamics->Load(AC_cfg)) {
cerr << "Aerodynamics not successfully loaded" << endl;
}
# ifdef SG_HAVE_STD_INCLUDES
# include <vector>
# include <iterator>
-# include <map>
# else
# include <vector.h>
# include <iterator.h>
-# include <map.h>
# endif
#else
# include <vector>
# include <iterator>
-# include <map>
#endif
#include "FGModel.h"
/** 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 */
vector <FGLGear> lGear;
- string AircraftPath;
- string EnginePath;
void ReadMetrics(FGConfigFile*);
void ReadPropulsion(FGConfigFile*);
void ReadFlightControls(FGConfigFile*);
class FGCoefficient
{
+public:
+ FGCoefficient(FGFDMExec*, FGConfigFile*);
+ ~FGCoefficient();
+
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};
int numInstances;
string description;
string name;
string method;
+ float Value(float, float);
+ float Value(float);
+ float Value(void);
float StaticValue;
eParam LookupR, LookupC;
MultVec multipliers;
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);
};
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-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") {
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);
{
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;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGGroundReactions::LoadGroundReactions(FGConfigFile* AC_cfg)
+bool FGGroundReactions::Load(FGConfigFile* AC_cfg)
{
-//
return true;
}
~FGGroundReactions();
bool Run(void);
- bool LoadGroundReactions(FGConfigFile* AC_cfg);
+ bool Load(FGConfigFile* AC_cfg);
private:
void Debug(void);
class FGPosition;
class FGAuxiliary;
class FGOutput;
+class FGConfigFile;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
/// 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);
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) {
cout << Translation->Getqbar() << ", ";
cout << Translation->GetVt() << ", ";
cout << Translation->GetUVW() << ", ";
+ cout << Translation->GetvAero() << ", ";
cout << Position->GetVel();
}
if (SubSystems & FGAircraft::ssForces) {
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) {
datafile << Translation->Getqbar() << ", ";
datafile << Translation->GetVt() << ", ";
datafile << Translation->GetUVW() << ", ";
+ datafile << Translation->GetvAero() << ", ";
datafile << Position->GetVel();
}
if (SubSystems & FGAircraft::ssForces) {
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");
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());
extern double globalSeaLevelRadius;
FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex),
- vUVW(3),
vVel(3),
vVelDot(3),
vRunwayNormal(3)
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();
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); }
}
private:
- FGColumnVector vUVW;
FGColumnVector vVel;
FGColumnVector vVelDot;
FGColumnVector vRunwayNormal;
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;
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
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGPropulsion::LoadPropulsion(FGConfigFile* AC_cfg)
+bool FGPropulsion::Load(FGConfigFile* AC_cfg)
{
string token, fullpath;
string engineFileName, engType;
@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();}
vForces(3),
vEuler(3),
vlastUVWdot(3),
- mVel(3,3)
+ mVel(3,3),
+ vAero(3)
{
Name = "FGTranslation";
qbar = 0;
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;
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; }
FGColumnVector vEuler;
FGColumnVector vlastUVWdot;
FGMatrix mVel;
+ FGColumnVector vAero;
float Vt, qbar, Mach;
float Mass, dt;
USEUNIT("FGOutput.cpp");
USEUNIT("FGPiston.cpp");
USEUNIT("FGPosition.cpp");
-USEUNIT("FGPropeller.cpp");
+USEUNIT("FGJSBBase.cpp");
USEUNIT("FGPropulsion.cpp");
USEUNIT("FGRocket.cpp");
USEUNIT("FGRotation.cpp");
USEUNIT("filtersjb\FGGradient.cpp");
USEUNIT("filtersjb\FGSummer.cpp");
USEUNIT("filtersjb\FGDeadBand.cpp");
+USEUNIT("FGPropeller.cpp");
//---------------------------------------------------------------------------
#endif