X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2FFGPropulsion.cpp;h=16be1ffdf21f79b940bb1acadd321671e6fefb29;hb=5fe0f047022bd168c7685169a8a3cedc8e93430e;hp=d95c8971ac22f80f0c098e488a8eda5372776729;hpb=96eff71a138a41069aa6b43c07f07c4822267098;p=flightgear.git diff --git a/src/FDM/JSBSim/FGPropulsion.cpp b/src/FDM/JSBSim/FGPropulsion.cpp index d95c8971a..16be1ffdf 100644 --- a/src/FDM/JSBSim/FGPropulsion.cpp +++ b/src/FDM/JSBSim/FGPropulsion.cpp @@ -57,8 +57,6 @@ INCLUDES static const char *IdSrc = "$Id$"; static const char *IdHdr = ID_PROPULSION; -extern short debug_lvl; - /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLASS IMPLEMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -70,8 +68,8 @@ FGPropulsion::FGPropulsion(FGFDMExec* exec) : FGModel(exec) numSelectedFuelTanks = numSelectedOxiTanks = 0; numTanks = numEngines = numThrusters = 0; numOxiTanks = numFuelTanks = 0; - Forces = new FGColumnVector(3); - Moments = new FGColumnVector(3); + Forces = new FGColumnVector3(3); + Moments = new FGColumnVector3(3); if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; } @@ -117,6 +115,8 @@ bool FGPropulsion::GetSteadyState(void) { float PowerAvailable; float currentThrust = 0, lastThrust=-1; dt = State->Getdt(); + int steady_count,j=0; + bool steady=false; Forces->InitMatrix(); Moments->InitMatrix(); @@ -125,10 +125,18 @@ bool FGPropulsion::GetSteadyState(void) { for (unsigned int i=0; iSetTrimMode(true); Thrusters[i]->SetdeltaT(dt*rate); - while (pow(currentThrust - lastThrust, 2.0) > currentThrust*0.00010) { + steady=false; + while (!steady && j < 6000) { PowerAvailable = Engines[i]->Calculate(Thrusters[i]->GetPowerRequired()); lastThrust = currentThrust; currentThrust = Thrusters[i]->Calculate(PowerAvailable); + if(fabs(lastThrust-currentThrust) < 0.0001) { + steady_count++; + if(steady_count > 120) { steady=true; } + } else { + steady_count=0; + } + j++; } *Forces += Thrusters[i]->GetBodyForces(); // sum body frame forces *Moments += Thrusters[i]->GetMoments(); // sum body frame moments @@ -143,6 +151,33 @@ bool FGPropulsion::GetSteadyState(void) { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +bool FGPropulsion::ICEngineStart(void) { + float PowerAvailable; + int j; + dt = State->Getdt(); + + Forces->InitMatrix(); + Moments->InitMatrix(); + + for (unsigned int i=0; iSetTrimMode(true); + Thrusters[i]->SetdeltaT(dt*rate); + j=0; + while (!Engines[i]->GetRunning() && j < 2000) { + PowerAvailable = Engines[i]->Calculate(Thrusters[i]->GetPowerRequired()); + Thrusters[i]->Calculate(PowerAvailable); + j++; + } + *Forces += Thrusters[i]->GetBodyForces(); // sum body frame forces + *Moments += Thrusters[i]->GetMoments(); // sum body frame moments + Engines[i]->SetTrimMode(false); + } + return true; +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + bool FGPropulsion::Load(FGConfigFile* AC_cfg) { string token, fullpath; @@ -152,6 +187,7 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg) string enginePath = FDMExec->GetEnginePath(); float xLoc, yLoc, zLoc, Pitch, Yaw; int Feed; + bool ThrottleAdded = false; # ifndef macintosh fullpath = enginePath + "/"; @@ -176,6 +212,7 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg) engType = Eng_cfg.GetValue(); FCS->AddThrottle(); + ThrottleAdded = true; if (engType == "FG_ROCKET") { Engines.push_back(new FGRocket(FDMExec, &Eng_cfg)); @@ -213,7 +250,7 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg) cout << " Z = " << zLoc << endl; cout << " Pitch = " << Pitch << endl; cout << " Yaw = " << Yaw << endl; - } + } Engines[numEngines]->SetPlacement(xLoc, yLoc, zLoc, Pitch, Yaw); numEngines++; @@ -288,6 +325,8 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg) AC_cfg->GetNextConfigLine(); } + if (!ThrottleAdded) FCS->AddThrottle(); // need to have at least one throttle + return true; } @@ -390,7 +429,7 @@ string FGPropulsion::GetPropulsionValues(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FGColumnVector& FGPropulsion::GetTanksCG(void) +FGColumnVector3& FGPropulsion::GetTanksCG(void) { iTank = Tanks.begin(); vXYZtank.InitMatrix(); @@ -419,7 +458,7 @@ float FGPropulsion::GetTanksWeight(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -float FGPropulsion::GetTanksIxx(const FGColumnVector& vXYZcg) +float FGPropulsion::GetTanksIxx(const FGColumnVector3& vXYZcg) { float I = 0.0; iTank = Tanks.begin(); @@ -432,7 +471,7 @@ float FGPropulsion::GetTanksIxx(const FGColumnVector& vXYZcg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -float FGPropulsion::GetTanksIyy(const FGColumnVector& vXYZcg) +float FGPropulsion::GetTanksIyy(const FGColumnVector3& vXYZcg) { float I = 0.0; iTank = Tanks.begin(); @@ -445,7 +484,7 @@ float FGPropulsion::GetTanksIyy(const FGColumnVector& vXYZcg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -float FGPropulsion::GetTanksIzz(const FGColumnVector& vXYZcg) +float FGPropulsion::GetTanksIzz(const FGColumnVector3& vXYZcg) { float I = 0.0; iTank = Tanks.begin(); @@ -458,7 +497,7 @@ float FGPropulsion::GetTanksIzz(const FGColumnVector& vXYZcg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -float FGPropulsion::GetTanksIxz(const FGColumnVector& vXYZcg) +float FGPropulsion::GetTanksIxz(const FGColumnVector3& vXYZcg) { float I = 0.0; iTank = Tanks.begin(); @@ -471,7 +510,7 @@ float FGPropulsion::GetTanksIxz(const FGColumnVector& vXYZcg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -float FGPropulsion::GetTanksIxy(const FGColumnVector& vXYZcg) +float FGPropulsion::GetTanksIxy(const FGColumnVector3& vXYZcg) { float I = 0.0; iTank = Tanks.begin();