static const char *IdSrc = "$Id$";
static const char *IdHdr = ID_PROPULSION;
-extern short debug_lvl;
-
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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;
}
float PowerAvailable;
float currentThrust = 0, lastThrust=-1;
dt = State->Getdt();
+ int steady_count,j=0;
+ bool steady=false;
Forces->InitMatrix();
Moments->InitMatrix();
for (unsigned int i=0; i<numEngines; i++) {
Engines[i]->SetTrimMode(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
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGPropulsion::ICEngineStart(void) {
+ float PowerAvailable;
+ int j;
+ dt = State->Getdt();
+
+ Forces->InitMatrix();
+ Moments->InitMatrix();
+
+ for (unsigned int i=0; i<numEngines; i++) {
+ Engines[i]->SetTrimMode(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;
string enginePath = FDMExec->GetEnginePath();
float xLoc, yLoc, zLoc, Pitch, Yaw;
int Feed;
+ bool ThrottleAdded = false;
# ifndef macintosh
fullpath = enginePath + "/";
engType = Eng_cfg.GetValue();
FCS->AddThrottle();
+ ThrottleAdded = true;
if (engType == "FG_ROCKET") {
Engines.push_back(new FGRocket(FDMExec, &Eng_cfg));
cout << " Z = " << zLoc << endl;
cout << " Pitch = " << Pitch << endl;
cout << " Yaw = " << Yaw << endl;
- }
+ }
Engines[numEngines]->SetPlacement(xLoc, yLoc, zLoc, Pitch, Yaw);
numEngines++;
AC_cfg->GetNextConfigLine();
}
+ if (!ThrottleAdded) FCS->AddThrottle(); // need to have at least one throttle
+
return true;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector& FGPropulsion::GetTanksCG(void)
+FGColumnVector3& FGPropulsion::GetTanksCG(void)
{
iTank = Tanks.begin();
vXYZtank.InitMatrix();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPropulsion::GetTanksIxx(const FGColumnVector& vXYZcg)
+float FGPropulsion::GetTanksIxx(const FGColumnVector3& vXYZcg)
{
float I = 0.0;
iTank = Tanks.begin();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPropulsion::GetTanksIyy(const FGColumnVector& vXYZcg)
+float FGPropulsion::GetTanksIyy(const FGColumnVector3& vXYZcg)
{
float I = 0.0;
iTank = Tanks.begin();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPropulsion::GetTanksIzz(const FGColumnVector& vXYZcg)
+float FGPropulsion::GetTanksIzz(const FGColumnVector3& vXYZcg)
{
float I = 0.0;
iTank = Tanks.begin();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPropulsion::GetTanksIxz(const FGColumnVector& vXYZcg)
+float FGPropulsion::GetTanksIxz(const FGColumnVector3& vXYZcg)
{
float I = 0.0;
iTank = Tanks.begin();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-float FGPropulsion::GetTanksIxy(const FGColumnVector& vXYZcg)
+float FGPropulsion::GetTanksIxy(const FGColumnVector3& vXYZcg)
{
float I = 0.0;
iTank = Tanks.begin();