Oct. 10, 2000 sync with JSBSim master repository.
This commit is contained in:
parent
b2d7a4e27a
commit
6caf599f2b
15 changed files with 141 additions and 85 deletions
|
@ -80,7 +80,7 @@ int FGJSBsim::init( double dt ) {
|
|||
current_options.get_aircraft() );
|
||||
|
||||
if (result) {
|
||||
FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft" << current_options.get_aircraft() );
|
||||
FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft " << current_options.get_aircraft() );
|
||||
} else {
|
||||
FG_LOG( FG_FLIGHT, FG_INFO, " aircraft" << current_options.get_aircraft()
|
||||
<< " does not exist");
|
||||
|
@ -103,7 +103,7 @@ int FGJSBsim::init( double dt ) {
|
|||
FG_LOG( FG_FLIGHT, FG_INFO, " Initializing JSBSim with:" );
|
||||
|
||||
FGInitialCondition *fgic = new FGInitialCondition(&FDMExec);
|
||||
fgic->SetAltitudeAGLFtIC(get_Altitude());
|
||||
fgic->SetAltitudeFtIC(get_Altitude());
|
||||
if((current_options.get_mach() < 0) && (current_options.get_vc() < 0 )) {
|
||||
fgic->SetUBodyFpsIC(current_options.get_uBody());
|
||||
fgic->SetVBodyFpsIC(current_options.get_vBody());
|
||||
|
|
|
@ -168,35 +168,20 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
|
|||
FGAircraft::~FGAircraft(void) {
|
||||
unsigned int i,j;
|
||||
|
||||
cout << " ~FGAircraft" << endl;
|
||||
if (Engine != NULL) {
|
||||
for (i=0; i<numEngines; i++)
|
||||
delete Engine[i];
|
||||
}
|
||||
cout << " Engine" << endl;
|
||||
|
||||
if (Tank != NULL) {
|
||||
for (i=0; i<numTanks; i++)
|
||||
delete Tank[i];
|
||||
}
|
||||
cout << " Tank" << endl;
|
||||
|
||||
cout << " NumAxes: " << 6 << endl;
|
||||
for (i=0; i<6; i++) {
|
||||
cout << " NumCoeffs: " << Coeff[i].size() << " " << &Coeff[i] << endl;
|
||||
for (j=0; j<Coeff[i].size(); j++) {
|
||||
|
||||
cout << " Coeff[" << i << "][" << j << "]: " << Coeff[i][j] << endl;
|
||||
delete Coeff[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
delete[] Coeff;
|
||||
cout << " Coeffs" << endl;
|
||||
|
||||
for (i=0; i<lGear.size(); i++) {
|
||||
delete lGear[i];
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -409,21 +394,15 @@ void FGAircraft::FMAero(void) {
|
|||
|
||||
void FGAircraft::FMGear(void) {
|
||||
|
||||
if (GearUp) {
|
||||
// crash routine
|
||||
} else {
|
||||
|
||||
// iGear = lGear.begin();
|
||||
// while (iGear != lGear.end()) {
|
||||
// vForces += iGear->Force();
|
||||
// vMoments += iGear->Moment();
|
||||
// iGear++;
|
||||
// }
|
||||
|
||||
for (unsigned int i=0;i<lGear.size();i++) {
|
||||
vForces += lGear[i]->Force();
|
||||
vMoments += lGear[i]->Moment();
|
||||
if ( !GearUp ) {
|
||||
vector <FGLGear>::iterator iGear = lGear.begin();
|
||||
while (iGear != lGear.end()) {
|
||||
vForces += iGear->Force();
|
||||
vMoments += iGear->Moment();
|
||||
iGear++;
|
||||
}
|
||||
} else {
|
||||
// Crash Routine
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -581,7 +560,7 @@ void FGAircraft::ReadUndercarriage(FGConfigFile* AC_cfg) {
|
|||
AC_cfg->GetNextConfigLine();
|
||||
|
||||
while ((token = AC_cfg->GetValue()) != "/UNDERCARRIAGE") {
|
||||
lGear.push_back(new FGLGear(AC_cfg, FDMExec));
|
||||
lGear.push_back(FGLGear(AC_cfg, FDMExec));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -737,10 +716,10 @@ string FGAircraft::GetGroundReactionStrings(void) {
|
|||
|
||||
for (unsigned int i=0;i<lGear.size();i++) {
|
||||
if (!firstime) GroundReactionStrings += ", ";
|
||||
GroundReactionStrings += (lGear[i]->GetName() + "_WOW, ");
|
||||
GroundReactionStrings += (lGear[i]->GetName() + "_compressLength, ");
|
||||
GroundReactionStrings += (lGear[i]->GetName() + "_compressSpeed, ");
|
||||
GroundReactionStrings += (lGear[i]->GetName() + "_Force");
|
||||
GroundReactionStrings += (lGear[i].GetName() + "_WOW, ");
|
||||
GroundReactionStrings += (lGear[i].GetName() + "_compressLength, ");
|
||||
GroundReactionStrings += (lGear[i].GetName() + "_compressSpeed, ");
|
||||
GroundReactionStrings += (lGear[i].GetName() + "_Force");
|
||||
|
||||
firstime = false;
|
||||
}
|
||||
|
@ -758,10 +737,10 @@ string FGAircraft::GetGroundReactionValues(void) {
|
|||
|
||||
for (unsigned int i=0;i<lGear.size();i++) {
|
||||
if (!firstime) GroundReactionValues += ", ";
|
||||
GroundReactionValues += string( lGear[i]->GetWOW()?"1":"0" ) + ", ";
|
||||
GroundReactionValues += (string(gcvt(lGear[i]->GetCompLen(), 5, buff)) + ", ");
|
||||
GroundReactionValues += (string(gcvt(lGear[i]->GetCompVel(), 6, buff)) + ", ");
|
||||
GroundReactionValues += (string(gcvt(lGear[i]->GetCompForce(), 10, buff)));
|
||||
GroundReactionValues += string( lGear[i].GetWOW()?"1":"0" ) + ", ";
|
||||
GroundReactionValues += (string(gcvt(lGear[i].GetCompLen(), 5, buff)) + ", ");
|
||||
GroundReactionValues += (string(gcvt(lGear[i].GetCompVel(), 6, buff)) + ", ");
|
||||
GroundReactionValues += (string(gcvt(lGear[i].GetCompForce(), 10, buff)));
|
||||
|
||||
firstime = false;
|
||||
}
|
||||
|
|
|
@ -125,6 +125,14 @@ INCLUDES
|
|||
DEFINITIONS
|
||||
*******************************************************************************/
|
||||
|
||||
/** Encapsulates an Aircraft and its systems.
|
||||
Owns all the parts (other classes) which make
|
||||
up this aircraft. This includes the Engines, Tanks, Propellers, Nozzles,
|
||||
aerodynamic and mass properties, landing gear, etc.
|
||||
@author Jon S. Berndt
|
||||
@version $Id$
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
CLASS DECLARATION
|
||||
*******************************************************************************/
|
||||
|
@ -136,16 +144,31 @@ class FGAircraft : public FGModel {
|
|||
enum {ePhi=1, eTht, ePsi};
|
||||
|
||||
public:
|
||||
FGAircraft(FGFDMExec*);
|
||||
/** Constructor
|
||||
@param Executive a pointer to the parent executive object
|
||||
*/
|
||||
FGAircraft(FGFDMExec *Executive);
|
||||
/// Destructor
|
||||
~FGAircraft(void);
|
||||
|
||||
/** Runs the model; called by the Executive
|
||||
@see JSBSim.cpp documentation
|
||||
@return bool returns false if no error
|
||||
*/
|
||||
bool Run(void);
|
||||
bool LoadAircraft(string, string, string);
|
||||
/** 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);
|
||||
inline string GetAircraftName(void) { return AircraftName; }
|
||||
inline void SetGearUp(bool tt) { GearUp = tt; }
|
||||
inline bool GetGearUp(void) { return GearUp; }
|
||||
inline int GetNumGearUnits(void) { return lGear.size(); }
|
||||
inline FGLGear* GetGearUnit(int ii) { return lGear[ii]; }
|
||||
inline FGLGear* GetGearUnit(int ii) { return &(lGear[ii]); }
|
||||
inline float GetWingArea(void) { return WingArea; }
|
||||
inline float GetWingSpan(void) { return WingSpan; }
|
||||
inline float Getcbar(void) { return cbar; }
|
||||
|
@ -177,8 +200,6 @@ public:
|
|||
string GetGroundReactionStrings(void);
|
||||
string GetGroundReactionValues(void);
|
||||
|
||||
vector <FGLGear>::iterator iGear;
|
||||
|
||||
enum { ssSimulation = 1,
|
||||
ssAerosurfaces = 2,
|
||||
ssRates = 4,
|
||||
|
@ -235,7 +256,7 @@ private:
|
|||
bool GearUp;
|
||||
|
||||
string Axis[6];
|
||||
vector <FGLGear*> lGear;
|
||||
vector <FGLGear> lGear;
|
||||
|
||||
string AircraftPath;
|
||||
string EnginePath;
|
||||
|
|
|
@ -51,8 +51,8 @@ FGControls::~FGControls() {
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.16 2000/10/09 19:16:22 curt
|
||||
// Oct. 9, 2000 - synced with latest JSBsim code.
|
||||
// Revision 1.17 2000/10/10 15:44:35 curt
|
||||
// Oct. 10, 2000 sync with JSBSim master repository.
|
||||
//
|
||||
// Revision 1.3 2000/04/26 10:55:57 jsb
|
||||
// Made changes as required by Curt to install JSBSim into FGFS
|
||||
|
|
|
@ -177,8 +177,8 @@ extern FGControls controls;
|
|||
|
||||
|
||||
// $Log$
|
||||
// Revision 1.15 2000/10/09 19:16:22 curt
|
||||
// Oct. 9, 2000 - synced with latest JSBsim code.
|
||||
// Revision 1.16 2000/10/10 15:44:35 curt
|
||||
// Oct. 10, 2000 sync with JSBSim master repository.
|
||||
//
|
||||
// Revision 1.6 2000/06/03 13:59:52 jsb
|
||||
// Changes for compatibility with MSVC
|
||||
|
|
|
@ -84,8 +84,21 @@ FGFDMExec::FGFDMExec(void)
|
|||
Auxiliary = 0;
|
||||
Output = 0;
|
||||
|
||||
// Instantiate this FDM Executive's Models
|
||||
allocated = false;
|
||||
terminate = false;
|
||||
frozen = false;
|
||||
}
|
||||
|
||||
FGFDMExec::~FGFDMExec(void){
|
||||
|
||||
DeAllocate();
|
||||
|
||||
}
|
||||
|
||||
bool FGFDMExec::Allocate(void) {
|
||||
|
||||
bool result=true;
|
||||
|
||||
Atmosphere = new FGAtmosphere(this);
|
||||
FCS = new FGFCS(this);
|
||||
Aircraft = new FGAircraft(this);
|
||||
|
@ -107,7 +120,9 @@ FGFDMExec::FGFDMExec(void)
|
|||
if (!Position->InitModel()) {cerr << "Position model init failed"; Error+=32;}
|
||||
if (!Auxiliary->InitModel()) {cerr << "Auxiliary model init failed"; Error+=64;}
|
||||
if (!Output->InitModel()) {cerr << "Output model init failed"; Error+=128;}
|
||||
|
||||
|
||||
if(Error > 0) result=false;
|
||||
|
||||
// Schedule a model. The second arg (the integer) is the pass number. For
|
||||
// instance, the atmosphere model gets executed every fifth pass it is called
|
||||
// by the executive. Everything else here gets executed each pass.
|
||||
|
@ -120,24 +135,41 @@ FGFDMExec::FGFDMExec(void)
|
|||
Schedule(Position, 1);
|
||||
Schedule(Auxiliary, 1);
|
||||
Schedule(Output, 1);
|
||||
|
||||
allocated = true;
|
||||
|
||||
return result;
|
||||
|
||||
terminate = false;
|
||||
frozen = false;
|
||||
}
|
||||
|
||||
bool FGFDMExec::DeAllocate(void) {
|
||||
if(allocated) {
|
||||
if ( Atmosphere != 0 ) delete Atmosphere;
|
||||
if ( FCS != 0 ) delete FCS;
|
||||
if ( Aircraft != 0 ) delete Aircraft;
|
||||
if ( Translation != 0 ) delete Translation;
|
||||
if ( Rotation != 0 ) delete Rotation;
|
||||
if ( Position != 0 ) delete Position;
|
||||
if ( Auxiliary != 0 ) delete Auxiliary;
|
||||
if ( Output != 0 ) delete Output;
|
||||
if ( State != 0 ) delete State;
|
||||
|
||||
FGFDMExec::~FGFDMExec(void){
|
||||
FirstModel = 0L;
|
||||
Error = 0;
|
||||
|
||||
State = 0;
|
||||
Atmosphere = 0;
|
||||
FCS = 0;
|
||||
Aircraft = 0;
|
||||
Translation = 0;
|
||||
Rotation = 0;
|
||||
Position = 0;
|
||||
Auxiliary = 0;
|
||||
Output = 0;
|
||||
|
||||
allocated = false;
|
||||
|
||||
if ( Atmosphere != NULL ) delete Atmosphere;
|
||||
if ( FCS != NULL ) delete FCS;
|
||||
if ( Aircraft != NULL ) delete Aircraft;
|
||||
if ( Translation != NULL ) delete Translation;
|
||||
if ( Rotation != NULL ) delete Rotation;
|
||||
if ( Position != NULL ) delete Position;
|
||||
if ( Auxiliary != NULL ) delete Auxiliary;
|
||||
if ( Output != NULL ) delete Output;
|
||||
if ( State != NULL ) delete State;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,7 +231,9 @@ bool FGFDMExec::RunIC(FGInitialCondition *fgic)
|
|||
|
||||
bool FGFDMExec::LoadModel(string APath, string EPath, string model)
|
||||
{
|
||||
AircraftPath = APath;
|
||||
DeAllocate();
|
||||
Allocate();
|
||||
AircraftPath = APath;
|
||||
EnginePath = EPath;
|
||||
return Aircraft->LoadAircraft(AircraftPath, EnginePath, model);
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ public:
|
|||
private:
|
||||
bool frozen;
|
||||
bool terminate;
|
||||
bool allocated;
|
||||
int Error;
|
||||
|
||||
string AircraftPath;
|
||||
|
@ -112,6 +113,9 @@ private:
|
|||
FGPosition* Position;
|
||||
FGAuxiliary* Auxiliary;
|
||||
FGOutput* Output;
|
||||
|
||||
bool Allocate(void);
|
||||
bool DeAllocate(void);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
|
|
@ -126,7 +126,7 @@ public:
|
|||
void SetAltitudeAGLFtIC(float tt);
|
||||
|
||||
//"vertical" flight path, recalculate theta
|
||||
inline void SetFlightPathAngleDegIC(float tt) { SetFlightPathAngleRadIC(gamma=tt*DEGTORAD); }
|
||||
inline void SetFlightPathAngleDegIC(float tt) { SetFlightPathAngleRadIC(tt*DEGTORAD); }
|
||||
void SetFlightPathAngleRadIC(float tt);
|
||||
//set speed first
|
||||
void SetClimbRateFpmIC(float tt);
|
||||
|
|
|
@ -83,6 +83,7 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
|
|||
|
||||
FGLGear::~FGLGear(void)
|
||||
{
|
||||
cout << "Destructing Landing Gear ..." << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -61,6 +61,7 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
|
|||
Type = otNone;
|
||||
Filename = "JSBSim.out";
|
||||
SubSystems = 0;
|
||||
enabled = true;
|
||||
|
||||
#ifdef FG_WITH_JSBSIM_SOCKET
|
||||
socket = new FGfdmSocket("localhost",1138);
|
||||
|
|
|
@ -87,7 +87,6 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
|
|||
{
|
||||
FDMExec = fdex;
|
||||
|
||||
adot = bdot = 0.0;
|
||||
a = 1000.0;
|
||||
sim_time = 0.0;
|
||||
dt = 1.0/120.0;
|
||||
|
@ -144,11 +143,11 @@ float FGState::GetParameter(eParam val_idx) {
|
|||
case FG_ALPHA:
|
||||
return FDMExec->GetTranslation()->Getalpha();
|
||||
case FG_ALPHADOT:
|
||||
return Getadot();
|
||||
return FDMExec->GetTranslation()->Getadot();
|
||||
case FG_BETA:
|
||||
return FDMExec->GetTranslation()->Getbeta();
|
||||
case FG_BETADOT:
|
||||
return Getbdot();
|
||||
return FDMExec->GetTranslation()->Getbdot();
|
||||
case FG_PITCHRATE:
|
||||
return (FDMExec->GetRotation()->GetPQR())(2);
|
||||
case FG_ROLLRATE:
|
||||
|
|
|
@ -81,9 +81,6 @@ public:
|
|||
void Initialize(FGInitialCondition *FGIC);
|
||||
bool StoreData(string);
|
||||
|
||||
inline float Getadot(void) { return adot; }
|
||||
inline float Getbdot(void) { return bdot; }
|
||||
|
||||
inline float Geta(void) { return a; }
|
||||
|
||||
inline float Getsim_time(void) { return sim_time; }
|
||||
|
@ -96,8 +93,6 @@ public:
|
|||
float GetParameter(string val_string);
|
||||
eParam GetParameterIndex(string val_string);
|
||||
|
||||
inline void Setadot(float tt) { adot = tt; }
|
||||
inline void Setbdot(float tt) { bdot = tt; }
|
||||
|
||||
inline void Seta(float tt) { a = tt; }
|
||||
|
||||
|
@ -125,7 +120,6 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
float adot, bdot; // alpha dot and beta dot
|
||||
float a; // speed of sound
|
||||
float sim_time, dt;
|
||||
float saved_dt;
|
||||
|
|
|
@ -87,6 +87,7 @@ FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex),
|
|||
Vt = 0.0;
|
||||
Mach = 0.0;
|
||||
alpha = beta = 0.0;
|
||||
adot = bdot = 0.0;
|
||||
rho = 0.002378;
|
||||
}
|
||||
|
||||
|
@ -127,7 +128,25 @@ bool FGTranslation::Run(void) {
|
|||
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;
|
||||
|
||||
|
||||
|
||||
// stolen, quite shamelessly, from LaRCsim
|
||||
float mUW = (vUVW(eU)*vUVW(eU) + vUVW(eW)*vUVW(eW));
|
||||
float signU=1;
|
||||
if (vUVW(eU) != 0.0)
|
||||
signU = vUVW(eU)/fabs(vUVW(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));
|
||||
}
|
||||
//
|
||||
|
||||
qbar = 0.5*rho*Vt*Vt;
|
||||
|
||||
Mach = Vt / State->Geta();
|
||||
|
|
|
@ -88,7 +88,8 @@ public:
|
|||
inline float Getqbar (void) { return qbar; }
|
||||
inline float GetVt (void) { return Vt; }
|
||||
inline float GetMach (void) { return Mach; }
|
||||
|
||||
inline float Getadot (void) { return adot; }
|
||||
inline float Getbdot (void) { return bdot; }
|
||||
|
||||
void SetUVW(FGColumnVector tt) { vUVW = tt; }
|
||||
|
||||
|
@ -97,6 +98,8 @@ public:
|
|||
inline void Setqbar (float tt) { qbar = tt; }
|
||||
inline void SetVt (float tt) { Vt = tt; }
|
||||
inline void SetMach (float tt) { Mach=tt; }
|
||||
inline void Setadot (float tt) { adot = tt; }
|
||||
inline void Setbdot (float tt) { bdot = tt; }
|
||||
|
||||
inline void SetAB(float t1, float t2) { alpha=t1; beta=t2; }
|
||||
|
||||
|
@ -115,6 +118,7 @@ private:
|
|||
float Vt, qbar, Mach;
|
||||
float Mass, dt;
|
||||
float alpha, beta;
|
||||
float adot,bdot;
|
||||
float rho;
|
||||
|
||||
void GetState(void);
|
||||
|
|
|
@ -144,24 +144,24 @@ int main(int argc, char** argv)
|
|||
while (FDMExec->GetState()->Getsim_time() <= 10.0)
|
||||
{
|
||||
// Fake an elevator ramp here after 1 second, hold for one second, ramp down
|
||||
/*
|
||||
|
||||
if (FDMExec->GetState()->Getsim_time() >= 1.00 &&
|
||||
FDMExec->GetState()->Getsim_time() < 2.0)
|
||||
{
|
||||
cmd = FDMExec->GetState()->Getsim_time() - 1.00;
|
||||
cmd = -(FDMExec->GetState()->Getsim_time() - 1.00)/2.0;
|
||||
} else if (FDMExec->GetState()->Getsim_time() >= 2.00 &&
|
||||
FDMExec->GetState()->Getsim_time() < 3.0)
|
||||
FDMExec->GetState()->Getsim_time() < 6.0)
|
||||
{
|
||||
cmd = 1.00;
|
||||
} else if (FDMExec->GetState()->Getsim_time() >= 3.00 &&
|
||||
FDMExec->GetState()->Getsim_time() < 4.0)
|
||||
cmd = -1.00/2.0;
|
||||
} else if (FDMExec->GetState()->Getsim_time() >= 6.00 &&
|
||||
FDMExec->GetState()->Getsim_time() < 7.0)
|
||||
{
|
||||
cmd = 4.0 - FDMExec->GetState()->Getsim_time();
|
||||
cmd = -(7.0 - FDMExec->GetState()->Getsim_time())/2.0;
|
||||
} else {
|
||||
cmd = 0.00;
|
||||
}
|
||||
FDMExec->GetFCS()->SetDeCmd(cmd); // input between -1 and 1
|
||||
*/
|
||||
|
||||
FDMExec->Run();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue