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";
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;
@ -450,7 +450,7 @@ void FGAircraft::FMAero(void)
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();
}
}
@ -485,7 +485,7 @@ void FGAircraft::FMAero(void)
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();
}
}
}

View file

@ -154,6 +154,7 @@ public:
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:

View file

@ -30,6 +30,9 @@ FUNCTIONAL DESCRIPTION
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
@ -56,6 +59,8 @@ INCLUDES
FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGAuxiliary";
vcas=veas=mach=qbar=pt=0;
psl=rhosl=1;
}
@ -66,10 +71,38 @@ FGAuxiliary::~FGAuxiliary()
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){}

View file

@ -26,6 +26,7 @@
HISTORY
--------------------------------------------------------------------------------
11/22/98 JSB Created
1/1/00 TP Added calcs and getters for VTAS, VCAS, VEAS, Vground, in knots
********************************************************************************
SENTRY
@ -57,9 +58,23 @@ public:
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);
};

View file

@ -55,7 +55,7 @@ SENTRY
#define NEEDED_CFG_VERSION 1.10
#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();
} else {
cerr << "Unable to open engine definition file " << engineName << endl;
cerr << "Unable to open engine definition file " << fullpath << endl;
}
EngineNumber = num;
@ -172,6 +172,8 @@ float FGEngine::CalcPistonThrust(void)
float v,h,pa;
Throttle = FCS->GetThrottle(EngineNumber);
Throttle /= 100;
v=State->GetVt();
h=State->Geth();
if(v < 10)

View file

@ -61,9 +61,9 @@ public:
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);

View file

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

View file

@ -58,10 +58,10 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGOutput";
sFirstPass = dFirstPass = true;
#ifdef FG_WITH_JSBSIM_SOCKET
socket = 0;
//#ifdef FG_WITH_JSBSIM_SOCKET
socket = new FGfdmSocket("localhost",1138);
#endif
//#endif
}
@ -75,7 +75,8 @@ bool FGOutput::Run(void)
{
if (!FGModel::Run()) {
// SocketOutput();
DelimitedOutput("JSBSimData.csv");
// DelimitedOutput("JSBSimData.csv");
// DelimitedOutput();
} else {
}
return false;
@ -120,7 +121,13 @@ void FGOutput::DelimitedOutput(void)
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;
}
@ -160,7 +167,13 @@ void FGOutput::DelimitedOutput(void)
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;
}
@ -205,7 +218,13 @@ void FGOutput::DelimitedOutput(string fname)
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;
}
@ -245,7 +264,13 @@ void FGOutput::DelimitedOutput(string fname)
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();
}
@ -291,6 +316,10 @@ void FGOutput::SocketOutput(void)
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();
}
@ -328,6 +357,10 @@ void FGOutput::SocketOutput(void)
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();
}

View file

@ -73,7 +73,8 @@ FGState::FGState(FGFDMExec* fdex)
h = 0.0;
a = 1000.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 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;
}