aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".cfg";
ifstream aircraftfile(aircraftDef.c_str());
cout << "Reading Aircraft Configuration File: " << aircraftDef << endl;
- Output->SocketStatusOutput("Reading Aircraft Configuration File: " + aircraftDef);
+ // Output->SocketStatusOutput("Reading Aircraft Configuration File: " + aircraftDef);
numTanks = numEngines = 0;
numSelectedOxiTanks = numSelectedFuelTanks = 0;
}
}
- if(!readAeroRp) {
+ if (!readAeroRp) {
Xrp = Xcg;
Yrp = Ycg;
Zrp = Zcg;
for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
for (ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++) {
F[axis_ctr] += Coeff[axis_ctr][ctr]->TotalValue();
- Coeff[axis_ctr][ctr]->DumpSD();
+// Coeff[axis_ctr][ctr]->DumpSD();
}
}
for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
for (ctr = 0; ctr < coeff_ctr[axis_ctr+3]; ctr++) {
Moments[axis_ctr] += Coeff[axis_ctr+3][ctr]->TotalValue();
- Coeff[axis_ctr+3][ctr]->DumpSD();
+// Coeff[axis_ctr+3][ctr]->DumpSD();
}
}
}
inline float GetIyy(void) {return Iyy;}
inline float GetIzz(void) {return Izz;}
inline float GetIxz(void) {return Ixz;}
+ inline float GetXcg(void) {return Xcg;}
inline int GetNumEngines(void) {return numEngines;}
private:
This class calculates various auxiliary parameters, mostly used by the visual
system
+REFERENCES
+ Anderson, John D. "Introduction to Flight", 3rd Edition, McGraw-Hill, 1989
+ pgs. 112-126
HISTORY
--------------------------------------------------------------------------------
01/26/99 JSB Created
FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGAuxiliary";
+ vcas=veas=mach=qbar=pt=0;
+ psl=rhosl=1;
}
bool FGAuxiliary::Run()
{
+ float A,B,D;
if (!FGModel::Run()) {
+ GetState();
+ if(mach < 1)
+ //calculate total pressure assuming isentropic flow
+ pt=p*pow((1 + 0.2*mach*mach),3.5);
+ else
+ {
+ // shock in front of pitot tube, we'll assume its normal and use
+ // the Rayleigh Pitot Tube Formula, i.e. the ratio of total
+ // pressure behind the shock to the static pressure in front
+ B=5.76*mach*mach/(5.6*mach*mach - 0.8);
+ // The denominator above is zero for Mach ~ 0.38, for which
+ // we'll never be here, so we're safe
+ D=(2.8*mach*mach-0.4)*0.4167;
+ pt=p*pow(B,3.5)*D;
+ }
+ A=pow(((pt-p)/psl+1),0.28571);
+ vcas=sqrt(7*psl/rhosl*(A-1));
+ veas=sqrt(2*qbar/rhosl);
} else {
}
return false;
}
-
+void FGAuxiliary::GetState(void)
+{
+ qbar=State->Getqbar();
+ mach=State->GetMach();
+ p=Atmosphere->GetPressure();
+ rhosl=Atmosphere->GetDensity(0);
+ psl=Atmosphere->GetPressure(0);
+}
+
+void FGAuxiliary::PutState(void){}
HISTORY
--------------------------------------------------------------------------------
11/22/98 JSB Created
+ 1/1/00 TP Added calcs and getters for VTAS, VCAS, VEAS, Vground, in knots
********************************************************************************
SENTRY
bool Run(void);
+
+ inline float GetVcalibratedFPS(void) { return vcas; }
+ inline float GetVcalibratedKTS(void) { return vcas*FPSTOKTS; }
+ inline float GetVequivalentFPS(void) { return veas; }
+ inline float GetVequivalentKTS(void) { return veas*FPSTOKTS; }
+
+
protected:
private:
+ float vcas;
+ float veas;
+ float mach;
+ float qbar,rhosl,rho,p,psl,pt;
+
+ void GetState(void);
+ void PutState(void);
};
#define NEEDED_CFG_VERSION 1.10
#define HPTOFTLBSSEC 550
-
+#define METERS_TO_FEET 3.2808
/******************************************************************************/
enginefile.close();
} else {
- cerr << "Unable to open engine definition file " << engineName << endl;
+ cerr << "Unable to open engine definition file " << fullpath << endl;
}
EngineNumber = num;
float v,h,pa;
Throttle = FCS->GetThrottle(EngineNumber);
+ Throttle /= 100;
+
v=State->GetVt();
h=State->Geth();
if(v < 10)
inline float GetDs(void) {return Ds;}
inline float GetThrottle(int ii) {return Throttle[ii];}
- inline void SetDa(float tt) {Da = tt*0.17;}
+ inline void SetDa(float tt) {Da = tt*0.30;}
inline void SetDe(float tt) {De = tt*0.60;}
- inline void SetDr(float tt) {Dr = tt*1.09;}
+ inline void SetDr(float tt) {Dr = -1*tt*0.50;}
inline void SetDf(float tt) {Df = tt;}
inline void SetDs(float tt) {Ds = tt;}
void SetThrottle(int ii, float tt);
};
/******************************************************************************/
-#endif
\ No newline at end of file
+#endif
Schedule(Translation, 1);
Schedule(Position, 1);
Schedule(Auxiliary, 1);
- Schedule(Output, 1);
+ Schedule(Output, 60);
terminate = false;
frozen = false;
{
Name = "FGOutput";
sFirstPass = dFirstPass = true;
-
-#ifdef FG_WITH_JSBSIM_SOCKET
+ socket = 0;
+//#ifdef FG_WITH_JSBSIM_SOCKET
socket = new FGfdmSocket("localhost",1138);
-#endif
+//#endif
}
{
if (!FGModel::Run()) {
// SocketOutput();
- DelimitedOutput("JSBSimData.csv");
+// DelimitedOutput("JSBSimData.csv");
+// DelimitedOutput();
} else {
}
return false;
cout << "Throttle,";
cout << "Aileron,";
cout << "Elevator,";
- cout << "Rudder";
+ cout << "Rudder,";
+ cout << "Ixx,";
+ cout << "Iyy,";
+ cout << "Izz,";
+ cout << "Ixz,";
+ cout << "Mass,";
+ cout << "X CG";
cout << endl;
dFirstPass = false;
}
cout << FCS->GetThrottle(0) << ",";
cout << FCS->GetDa() << ",";
cout << FCS->GetDe() << ",";
- cout << FCS->GetDr() << "";
+ cout << FCS->GetDr() << ",";
+ cout << Aircraft->GetIxx() << ",";
+ cout << Aircraft->GetIyy() << ",";
+ cout << Aircraft->GetIzz() << ",";
+ cout << Aircraft->GetIxz() << ",";
+ cout << Aircraft->GetMass() << ",";
+ cout << Aircraft->GetXcg() << "";
cout << endl;
}
datafile << "Throttle,";
datafile << "Aileron,";
datafile << "Elevator,";
- datafile << "Rudder";
+ datafile << "Rudder,";
+ datafile << "Ixx,";
+ datafile << "Iyy,";
+ datafile << "Izz,";
+ datafile << "Ixz,";
+ datafile << "Mass,";
+ datafile << "X CG";
datafile << endl;
sFirstPass = false;
}
datafile << FCS->GetThrottle(0) << ",";
datafile << FCS->GetDa() << ",";
datafile << FCS->GetDe() << ",";
- datafile << FCS->GetDr() << "";
+ datafile << FCS->GetDr() << ",";
+ datafile << Aircraft->GetIxx() << ",";
+ datafile << Aircraft->GetIyy() << ",";
+ datafile << Aircraft->GetIzz() << ",";
+ datafile << Aircraft->GetIxz() << ",";
+ datafile << Aircraft->GetMass() << ",";
+ datafile << Aircraft->GetXcg() << "";
datafile << endl;
datafile.flush();
}
socket->Append("L");
socket->Append("M");
socket->Append("N");
+ socket->Append("Throttle");
+ socket->Append("Aileron");
+ socket->Append("Elevator");
+ socket->Append("Rudder");
sFirstPass = false;
socket->Send();
}
socket->Append(Aircraft->GetL());
socket->Append(Aircraft->GetM());
socket->Append(Aircraft->GetN());
+ socket->Append(FCS->GetThrottle(0));
+ socket->Append(FCS->GetDa());
+ socket->Append(FCS->GetDe());
+ socket->Append(FCS->GetDr());
socket->Send();
}
h = 0.0;
a = 1000.0;
qbar = 0.0;
- sim_time = dt = 0.1;
+ sim_time = 0.0;
+ dt = 1.0/120.0;
}
float FGUtility::ToGeodetic()
{
- float Latitude, Radius, Altitude;
- float tanLat, xAlpha, muAlpha, sinmuAlpha, denom, rhoAlpha, dMu;
- float lPoint, lambdaSL, sinlambdaSL, dLambda, rAlpha;
-
- Latitude = State->Getlatitude();
- Radius = State->Geth() + EARTHRAD;
-
- if (( M_PI_2 - Latitude < ONESECOND) ||
- ( M_PI_2 + Latitude < ONESECOND)) { // Near a pole
- } else {
- tanLat = tan(Latitude);
- xAlpha = ECCENT*EARTHRAD /
- sqrt(tanLat*tanLat + ECCENTSQRD);
- muAlpha = atan2(sqrt(EARTHRADSQRD - xAlpha*xAlpha), ECCENT*xAlpha);
-
- if (Latitude < 0.0) muAlpha = -muAlpha;
-
- sinmuAlpha = sin(muAlpha);
- dLambda = muAlpha - Latitude;
- rAlpha = xAlpha / cos(Latitude);
- lPoint = Radius - rAlpha;
- Altitude = lPoint*cos(dLambda);
- denom = sqrt(1-EPS*EPS*sinmuAlpha*sinmuAlpha);
- rhoAlpha = EARTHRAD*(1.0 - EPS) / (denom*denom*denom);
- dMu = atan2(lPoint*sin(dLambda),rhoAlpha + Altitude);
- State->SetGeodeticLat(muAlpha - dMu);
- lambdaSL = atan(ECCENTSQRD*tan(muAlpha - dMu));
- sinlambdaSL = sin(lambdaSL);
- SeaLevelR = sqrt(EARTHRADSQRD / (1 + INVECCENTSQRDM1* sinlambdaSL*sinlambdaSL));
- }
- return 0.0;
}
float FGUtility:: FromGeodetic()
{
- float lambdaSL, sinlambdaSL, coslambdaSL, sinMu, cosMu, py, px;
- float Altitude, SeaLevelR, Radius;
-
- Radius = State->Geth() + EARTHRAD;
- lambdaSL = atan(ECCENTSQRD*tan(State->GetGeodeticLat()));
- sinlambdaSL = sin(lambdaSL);
- coslambdaSL = cos(lambdaSL);
- sinMu = sin(State->GetGeodeticLat());
- cosMu = cos(State->GetGeodeticLat());
- SeaLevelR = sqrt(EARTHRADSQRD /
- (1 + INVECCENTSQRDM1*sinlambdaSL*sinlambdaSL));
- Altitude = Radius - SeaLevelR;
- px = SeaLevelR*coslambdaSL + Altitude*cosMu;
- py = SeaLevelR*sinlambdaSL + Altitude*sinMu;
- State->Setlatitude(atan2(py,px));
- return 0.0;
}