1
0
Fork 0

Updates from Jon and Tony.

This commit is contained in:
curt 2000-01-10 21:07:00 +00:00
parent eedbfddbf1
commit c722481805
11 changed files with 104 additions and 66 deletions

View file

@ -165,7 +165,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".cfg"; aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".cfg";
ifstream aircraftfile(aircraftDef.c_str()); ifstream aircraftfile(aircraftDef.c_str());
cout << "Reading Aircraft Configuration File: " << aircraftDef << endl; cout << "Reading Aircraft Configuration File: " << aircraftDef << endl;
Output->SocketStatusOutput("Reading Aircraft Configuration File: " + aircraftDef); // Output->SocketStatusOutput("Reading Aircraft Configuration File: " + aircraftDef);
numTanks = numEngines = 0; numTanks = numEngines = 0;
numSelectedOxiTanks = numSelectedFuelTanks = 0; numSelectedOxiTanks = numSelectedFuelTanks = 0;
@ -450,7 +450,7 @@ void FGAircraft::FMAero(void)
for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) { for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
for (ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++) { for (ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++) {
F[axis_ctr] += Coeff[axis_ctr][ctr]->TotalValue(); F[axis_ctr] += Coeff[axis_ctr][ctr]->TotalValue();
Coeff[axis_ctr][ctr]->DumpSD(); // Coeff[axis_ctr][ctr]->DumpSD();
} }
} }
@ -485,7 +485,7 @@ void FGAircraft::FMAero(void)
for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) { for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
for (ctr = 0; ctr < coeff_ctr[axis_ctr+3]; ctr++) { for (ctr = 0; ctr < coeff_ctr[axis_ctr+3]; ctr++) {
Moments[axis_ctr] += Coeff[axis_ctr+3][ctr]->TotalValue(); Moments[axis_ctr] += Coeff[axis_ctr+3][ctr]->TotalValue();
Coeff[axis_ctr+3][ctr]->DumpSD(); // Coeff[axis_ctr+3][ctr]->DumpSD();
} }
} }
} }

View file

@ -154,6 +154,7 @@ public:
inline float GetIyy(void) {return Iyy;} inline float GetIyy(void) {return Iyy;}
inline float GetIzz(void) {return Izz;} inline float GetIzz(void) {return Izz;}
inline float GetIxz(void) {return Ixz;} inline float GetIxz(void) {return Ixz;}
inline float GetXcg(void) {return Xcg;}
inline int GetNumEngines(void) {return numEngines;} inline int GetNumEngines(void) {return numEngines;}
private: private:

View file

@ -30,6 +30,9 @@ FUNCTIONAL DESCRIPTION
This class calculates various auxiliary parameters, mostly used by the visual This class calculates various auxiliary parameters, mostly used by the visual
system system
REFERENCES
Anderson, John D. "Introduction to Flight", 3rd Edition, McGraw-Hill, 1989
pgs. 112-126
HISTORY HISTORY
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
01/26/99 JSB Created 01/26/99 JSB Created
@ -56,6 +59,8 @@ INCLUDES
FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex) FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
{ {
Name = "FGAuxiliary"; Name = "FGAuxiliary";
vcas=veas=mach=qbar=pt=0;
psl=rhosl=1;
} }
@ -66,10 +71,38 @@ FGAuxiliary::~FGAuxiliary()
bool FGAuxiliary::Run() bool FGAuxiliary::Run()
{ {
float A,B,D;
if (!FGModel::Run()) { 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 { } else {
} }
return false; 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){}

View file

@ -26,6 +26,7 @@
HISTORY HISTORY
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
11/22/98 JSB Created 11/22/98 JSB Created
1/1/00 TP Added calcs and getters for VTAS, VCAS, VEAS, Vground, in knots
******************************************************************************** ********************************************************************************
SENTRY SENTRY
@ -57,9 +58,23 @@ public:
bool Run(void); 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: protected:
private: private:
float vcas;
float veas;
float mach;
float qbar,rhosl,rho,p,psl,pt;
void GetState(void);
void PutState(void);
}; };

View file

@ -55,7 +55,7 @@ SENTRY
#define NEEDED_CFG_VERSION 1.10 #define NEEDED_CFG_VERSION 1.10
#define HPTOFTLBSSEC 550 #define HPTOFTLBSSEC 550
#define METERS_TO_FEET 3.2808
/******************************************************************************/ /******************************************************************************/

View file

@ -130,7 +130,7 @@ FGEngine::FGEngine(FGFDMExec* fdex, string enginePath, string engineName, int nu
enginefile.close(); enginefile.close();
} else { } else {
cerr << "Unable to open engine definition file " << engineName << endl; cerr << "Unable to open engine definition file " << fullpath << endl;
} }
EngineNumber = num; EngineNumber = num;
@ -172,6 +172,8 @@ float FGEngine::CalcPistonThrust(void)
float v,h,pa; float v,h,pa;
Throttle = FCS->GetThrottle(EngineNumber); Throttle = FCS->GetThrottle(EngineNumber);
Throttle /= 100;
v=State->GetVt(); v=State->GetVt();
h=State->Geth(); h=State->Geth();
if(v < 10) if(v < 10)

View file

@ -61,9 +61,9 @@ public:
inline float GetDs(void) {return Ds;} inline float GetDs(void) {return Ds;}
inline float GetThrottle(int ii) {return Throttle[ii];} 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 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 SetDf(float tt) {Df = tt;}
inline void SetDs(float tt) {Ds = tt;} inline void SetDs(float tt) {Ds = tt;}
void SetThrottle(int ii, float tt); void SetThrottle(int ii, float tt);

View file

@ -119,7 +119,7 @@ FGFDMExec::FGFDMExec(void)
Schedule(Translation, 1); Schedule(Translation, 1);
Schedule(Position, 1); Schedule(Position, 1);
Schedule(Auxiliary, 1); Schedule(Auxiliary, 1);
Schedule(Output, 1); Schedule(Output, 60);
terminate = false; terminate = false;
frozen = false; frozen = false;

View file

@ -58,10 +58,10 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
{ {
Name = "FGOutput"; Name = "FGOutput";
sFirstPass = dFirstPass = true; sFirstPass = dFirstPass = true;
socket = 0;
#ifdef FG_WITH_JSBSIM_SOCKET //#ifdef FG_WITH_JSBSIM_SOCKET
socket = new FGfdmSocket("localhost",1138); socket = new FGfdmSocket("localhost",1138);
#endif //#endif
} }
@ -75,7 +75,8 @@ bool FGOutput::Run(void)
{ {
if (!FGModel::Run()) { if (!FGModel::Run()) {
// SocketOutput(); // SocketOutput();
DelimitedOutput("JSBSimData.csv"); // DelimitedOutput("JSBSimData.csv");
// DelimitedOutput();
} else { } else {
} }
return false; return false;
@ -120,7 +121,13 @@ void FGOutput::DelimitedOutput(void)
cout << "Throttle,"; cout << "Throttle,";
cout << "Aileron,"; cout << "Aileron,";
cout << "Elevator,"; cout << "Elevator,";
cout << "Rudder"; cout << "Rudder,";
cout << "Ixx,";
cout << "Iyy,";
cout << "Izz,";
cout << "Ixz,";
cout << "Mass,";
cout << "X CG";
cout << endl; cout << endl;
dFirstPass = false; dFirstPass = false;
} }
@ -160,7 +167,13 @@ void FGOutput::DelimitedOutput(void)
cout << FCS->GetThrottle(0) << ","; cout << FCS->GetThrottle(0) << ",";
cout << FCS->GetDa() << ","; cout << FCS->GetDa() << ",";
cout << FCS->GetDe() << ","; 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; cout << endl;
} }
@ -205,7 +218,13 @@ void FGOutput::DelimitedOutput(string fname)
datafile << "Throttle,"; datafile << "Throttle,";
datafile << "Aileron,"; datafile << "Aileron,";
datafile << "Elevator,"; datafile << "Elevator,";
datafile << "Rudder"; datafile << "Rudder,";
datafile << "Ixx,";
datafile << "Iyy,";
datafile << "Izz,";
datafile << "Ixz,";
datafile << "Mass,";
datafile << "X CG";
datafile << endl; datafile << endl;
sFirstPass = false; sFirstPass = false;
} }
@ -245,7 +264,13 @@ void FGOutput::DelimitedOutput(string fname)
datafile << FCS->GetThrottle(0) << ","; datafile << FCS->GetThrottle(0) << ",";
datafile << FCS->GetDa() << ","; datafile << FCS->GetDa() << ",";
datafile << FCS->GetDe() << ","; 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 << endl;
datafile.flush(); datafile.flush();
} }
@ -291,6 +316,10 @@ void FGOutput::SocketOutput(void)
socket->Append("L"); socket->Append("L");
socket->Append("M"); socket->Append("M");
socket->Append("N"); socket->Append("N");
socket->Append("Throttle");
socket->Append("Aileron");
socket->Append("Elevator");
socket->Append("Rudder");
sFirstPass = false; sFirstPass = false;
socket->Send(); socket->Send();
} }
@ -328,6 +357,10 @@ void FGOutput::SocketOutput(void)
socket->Append(Aircraft->GetL()); socket->Append(Aircraft->GetL());
socket->Append(Aircraft->GetM()); socket->Append(Aircraft->GetM());
socket->Append(Aircraft->GetN()); socket->Append(Aircraft->GetN());
socket->Append(FCS->GetThrottle(0));
socket->Append(FCS->GetDa());
socket->Append(FCS->GetDe());
socket->Append(FCS->GetDr());
socket->Send(); socket->Send();
} }

View file

@ -73,7 +73,8 @@ FGState::FGState(FGFDMExec* fdex)
h = 0.0; h = 0.0;
a = 1000.0; a = 1000.0;
qbar = 0.0; qbar = 0.0;
sim_time = dt = 0.1; sim_time = 0.0;
dt = 1.0/120.0;
} }

View file

@ -82,57 +82,10 @@ FGUtility::~FGUtility()
float FGUtility::ToGeodetic() 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 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;
} }