1
0
Fork 0

0429 updates from Jon.

This commit is contained in:
curt 2000-04-28 19:59:46 +00:00
parent 418279fdd4
commit 1868e44ee4
21 changed files with 114 additions and 123 deletions

View file

@ -217,12 +217,12 @@ int FGJSBsim::copy_from_JSBsim() {
// ***FIXME*** set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
set_Mach_number( FDMExec.GetState()->GetMach());
set_Mach_number( FDMExec.GetTranslation()->GetMach());
// Positions
double lat_geoc = FDMExec.GetState()->Getlatitude();
double lon = FDMExec.GetState()->Getlongitude();
double alt = FDMExec.GetState()->Geth();
double lat_geoc = FDMExec.GetPosition()->GetLatitude();
double lon = FDMExec.GetPosition()->GetLongitude();
double alt = FDMExec.GetPosition()->Geth();
double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc;
fgGeocToGeod( lat_geoc, EQUATORIAL_RADIUS_M + alt * FEET_TO_METER,
&lat_geod, &tmp_alt, &sl_radius1 );

View file

@ -150,7 +150,7 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
AxisIdx["PITCH"] = 4;
AxisIdx["YAW"] = 5;
numTanks = numEngines = 0;
numTanks = numEngines = numSelectedFuelTanks = numSelectedOxiTanks = 0;
}
@ -288,7 +288,6 @@ void FGAircraft::MassChange()
Weight += Tank[t]->GetContents();
Mass = Weight / GRAVITY;
// Calculate new CG here.
Tw = 0;

View file

@ -85,7 +85,7 @@ bool FGAtmosphere::Run(void)
{
if (!FGModel::Run()) { // if false then execute this Run()
if (!useExternal) {
h = State->Geth();
h = Position->Geth();
Calculate(h);
} else {
density = exDensity;
@ -99,11 +99,11 @@ bool FGAtmosphere::Run(void)
return false;
}
void FGAtmosphere::Calculate(float altitude)
{
//see reference [1]
float slope,reftemp,refpress,refdens;
int i=0;
float htab[]={0,36089,82020,154198,173882,259183,295272,344484}; //ft.

View file

@ -104,11 +104,10 @@ bool FGAuxiliary::Run()
void FGAuxiliary::GetState(void)
{
qbar = State->Getqbar();
mach = State->GetMach();
qbar = Translation->Getqbar();
mach = Translation->GetMach();
p = Atmosphere->GetPressure();
rhosl = Atmosphere->GetDensitySL();
psl = Atmosphere->GetPressureSL();
}
void FGAuxiliary::PutState(void){}

View file

@ -74,8 +74,6 @@ private:
float qbar,rhosl,rho,p,psl,pt;
void GetState(void);
void PutState(void);
};
/******************************************************************************/

View file

@ -51,6 +51,12 @@ FGControls::~FGControls() {
// $Log$
// Revision 1.9 2000/04/28 17:59:46 curt
// 0429 updates from Jon.
//
// Revision 1.3 2000/04/26 10:55:57 jsb
// Made changes as required by Curt to install JSBSim into FGFS
//
// Revision 1.8 2000/04/24 21:49:06 curt
// Updated JSBsim code.
//

View file

@ -177,6 +177,12 @@ extern FGControls controls;
// $Log$
// Revision 1.8 2000/04/28 17:59:46 curt
// 0429 updates from Jon.
//
// Revision 1.4 2000/04/26 10:55:57 jsb
// Made changes as required by Curt to install JSBSim into FGFS
//
// Revision 1.7 2000/04/24 21:49:07 curt
// Updated JSBsim code.
//

View file

@ -134,7 +134,7 @@ FGEngine::FGEngine(FGFDMExec* fdex, string enginePath, string engineName, int nu
}
EngineNumber = num;
Thrust = 0.0;
Thrust = PctPower = 0.0;
Starved = Flameout = false;
}
@ -173,9 +173,9 @@ float FGEngine::CalcPistonThrust(void)
Throttle = FCS->GetThrottlePos(EngineNumber);
Throttle /= 100;
v=State->GetVt();
h=State->Geth();
v=Translation->GetVt();
h=Position->Geth();
if(v < 10)
v=10;
if(h < 0)

View file

@ -63,6 +63,12 @@ INCLUDES
FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
{
Name = "FGFCS";
for (int i=0; i < MAX_ENGINES; i++) {
ThrottleCmd[i] = 0.0;
ThrottlePos[i] = 0.0;
}
DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = 0.0;
DaPos = DePos = DrPos = DfPos = DsbPos = DspPos = 0.0;
}
/******************************************************************************/
@ -109,6 +115,8 @@ void FGFCS::SetThrottlePos(int engineNum, float setting)
/******************************************************************************/
#pragma warn -8030
bool FGFCS::LoadFCS(FGConfigFile* AC_cfg)
{
string token;
@ -146,6 +154,8 @@ bool FGFCS::LoadFCS(FGConfigFile* AC_cfg)
return true;
}
#pragma warn .8030
/******************************************************************************/
float FGFCS::GetComponentOutput(int idx)

View file

@ -51,6 +51,7 @@ void dealloc(double **A, int rows)
FGMatrix::FGMatrix(const unsigned int r, const unsigned int c) : rows(r), cols(c)
{
data = FGalloc(rows,cols);
InitMatrix();
rowCtr = colCtr = 1;
}

View file

@ -118,8 +118,8 @@ void FGOutput::DelimitedOutput(void)
}
cout << State->Getsim_time() << ",";
cout << State->Getqbar() << ",";
cout << State->GetVt() << ",";
cout << Translation->Getqbar() << ",";
cout << Translation->GetVt() << ",";
cout << FCS->GetThrottlePos(0) << ",";
cout << FCS->GetDaPos() << ",";
cout << FCS->GetDePos() << ",";
@ -133,14 +133,14 @@ void FGOutput::DelimitedOutput(void)
cout << Aircraft->GetXYZcg() << ",";
cout << Aircraft->GetForces() << ",";
cout << Aircraft->GetMoments() << ",";
cout << State->Geth() << ",";
cout << Position->Geth() << ",";
cout << Rotation->GetEuler() << ",";
cout << Rotation->GetPQR() << ",";
cout << Translation->GetUVW() << ",";
cout << Translation->Getalpha() << ",";
cout << Position->GetVel() << ",";
cout << State->Getlatitude() << ",";
cout << State->Getlongitude();
cout << Position->GetLatitude() << ",";
cout << Position->GetLongitude();
cout << endl;
}
@ -179,8 +179,8 @@ void FGOutput::DelimitedOutput(string fname)
}
datafile << State->Getsim_time() << ",";
datafile << State->Getqbar() << ",";
datafile << State->GetVt() << ",";
datafile << Translation->Getqbar() << ",";
datafile << Translation->GetVt() << ",";
datafile << FCS->GetThrottlePos(0) << ",";
datafile << FCS->GetDaPos() << ",";
datafile << FCS->GetDePos() << ",";
@ -194,14 +194,14 @@ void FGOutput::DelimitedOutput(string fname)
datafile << Aircraft->GetXYZcg() << ",";
datafile << Aircraft->GetForces() << ",";
datafile << Aircraft->GetMoments() << ",";
datafile << State->Geth() << ",";
datafile << Position->Geth() << ",";
datafile << Rotation->GetEuler() << ",";
datafile << Rotation->GetPQR() << ",";
datafile << Translation->GetUVW() << ",";
datafile << Translation->Getalpha() << ",";
datafile << Position->GetVel() << ",";
datafile << State->Getlatitude() << ",";
datafile << State->Getlongitude();
datafile << Position->GetLatitude() << ",";
datafile << Position->GetLongitude();
datafile << endl;
datafile.flush();
}
@ -259,12 +259,12 @@ void FGOutput::SocketOutput(void)
socket->Clear();
socket->Append(State->Getsim_time());
socket->Append(State->Geth());
socket->Append(Position->Geth());
socket->Append(Rotation->Getphi());
socket->Append(Rotation->Gettht());
socket->Append(Rotation->Getpsi());
socket->Append(Atmosphere->GetDensity());
socket->Append(State->GetVt());
socket->Append(Translation->GetVt());
socket->Append(Translation->GetU());
socket->Append(Translation->GetV());
socket->Append(Translation->GetW());
@ -283,9 +283,9 @@ void FGOutput::SocketOutput(void)
socket->Append(Aircraft->GetFx());
socket->Append(Aircraft->GetFy());
socket->Append(Aircraft->GetFz());
socket->Append(State->Getlatitude());
socket->Append(State->Getlongitude());
socket->Append(State->Getqbar());
socket->Append(Position->GetLatitude());
socket->Append(Position->GetLongitude());
socket->Append(Translation->Getqbar());
socket->Append(Translation->Getalpha());
socket->Append(Aircraft->GetL());
socket->Append(Aircraft->GetM());

View file

@ -87,6 +87,8 @@ FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex),
Name = "FGPosition";
LongitudeDot = LatitudeDot = RadiusDot = 0.0;
lastLongitudeDot = lastLatitudeDot = lastRadiusDot = 0.0;
Longitude = Latitude = 0.0;
h = 0.0;
}
/******************************************************************************/
@ -116,11 +118,12 @@ bool FGPosition:: Run(void)
Latitude += 0.5*dt*rate*(LatitudeDot + lastLatitudeDot);
Radius += 0.5*dt*rate*(RadiusDot + lastRadiusDot);
h = Radius - EARTHRAD;
lastLatitudeDot = LatitudeDot;
lastLongitudeDot = LongitudeDot;
lastRadiusDot = RadiusDot;
PutState();
return false;
} else {
@ -136,22 +139,8 @@ void FGPosition::GetState(void)
vUVW = Translation->GetUVW();
Latitude = State->Getlatitude();
Longitude = State->Getlongitude();
invMass = 1.0 / Aircraft->GetMass();
invRadius = 1.0 / (State->Geth() + EARTHRAD);
Radius = State->Geth() + EARTHRAD;
invRadius = 1.0 / (h + EARTHRAD);
Radius = h + EARTHRAD;
}
/******************************************************************************/
void FGPosition::PutState(void)
{
State->Setlatitude(Latitude);
State->Setlongitude(Longitude);
State->Seth(Radius - EARTHRAD);
}
/******************************************************************************/

View file

@ -57,14 +57,13 @@ class FGPosition : public FGModel
FGColumnVector vVel;
float Vee, invMass, invRadius;
double Radius;
double Radius, h;
float LatitudeDot, LongitudeDot, RadiusDot;
float lastLatitudeDot, lastLongitudeDot, lastRadiusDot;
float Longitude, Latitude;
float dt;
void GetState(void);
void PutState(void);
public:
FGPosition(FGFDMExec*);
@ -75,6 +74,13 @@ public:
inline float GetVn(void) {return vVel(1);}
inline float GetVe(void) {return vVel(2);}
inline float GetVd(void) {return vVel(3);}
inline float Geth(void) {return h;}
inline float GetLatitude(void) {return Latitude;}
inline float GetLongitude(void) {return Longitude;}
void SetvVel(const FGColumnVector& v) {vVel = v;}
void SetLatitude(float tt) {Latitude = tt;}
void SetLongitude(float tt) {Longitude = tt;}
void Seth(float tt) {h = tt;}
bool Run(void);
};

View file

@ -76,6 +76,8 @@ using namespace std;
CLASS DECLARATION
*******************************************************************************/
#pragma warn -8026
class FGRotation : public FGModel
{
FGColumnVector vPQR;
@ -101,6 +103,7 @@ public:
inline float Gettht(void) {return vEuler(2);}
inline float Getpsi(void) {return vEuler(3);}
};
#pragma warn .8026
/******************************************************************************/
#endif

View file

@ -70,12 +70,8 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
{
FDMExec = fdex;
Vt = 0.0;
latitude = longitude = 0.0;
adot = bdot = 0.0;
h = 0.0;
a = 1000.0;
qbar = 0.0;
sim_time = 0.0;
dt = 1.0/120.0;
@ -128,6 +124,7 @@ bool FGState::Reset(string path, string acname, string fname)
string resetDef;
float U, V, W;
float phi, tht, psi;
float latitude, longitude, h;
resetDef = path + "/" + acname + "/" + fname;
@ -145,6 +142,10 @@ bool FGState::Reset(string path, string acname, string fname)
resetfile >> h;
resetfile.close();
FDMExec->GetPosition()->SetLatitude(latitude*DEGTORAD);
FDMExec->GetPosition()->SetLongitude(longitude*DEGTORAD);
FDMExec->GetPosition()->Seth(h);
Initialize(U, V, W, phi*DEGTORAD, tht*DEGTORAD, psi*DEGTORAD,
latitude*DEGTORAD, longitude*DEGTORAD, h);
@ -165,12 +166,15 @@ void FGState::Initialize(float U, float V, float W,
float Latitude, float Longitude, float H)
{
FGColumnVector vUVW(3);
FGColumnVector vLocalVelNED(3);
FGColumnVector vEuler(3);
float alpha, beta, gamma;
float qbar, Vt;
FDMExec->GetPosition()->SetLatitude(Latitude*DEGTORAD);
FDMExec->GetPosition()->SetLongitude(Longitude*DEGTORAD);
FDMExec->GetPosition()->Seth(H);
latitude = Latitude;
longitude = Longitude;
h = H;
FDMExec->GetAtmosphere()->Run();
gamma = 0.0;
@ -185,14 +189,22 @@ void FGState::Initialize(float U, float V, float W,
vUVW << U << V << W;
FDMExec->GetTranslation()->SetUVW(vUVW);
vEuler << phi << tht << psi;
FDMExec->GetRotation()->SetEuler(vEuler);
FDMExec->GetTranslation()->SetABG(alpha, beta, gamma);
Vt = sqrt(U*U + V*V + W*W);
FDMExec->GetTranslation()->SetVt(Vt);
qbar = 0.5*(U*U + V*V + W*W)*FDMExec->GetAtmosphere()->GetDensity();
FDMExec->GetTranslation()->Setqbar(qbar);
InitMatrices(phi, tht, psi);
vLocalVelNED = mTb2l*vUVW;
FDMExec->GetPosition()->SetvVel(vLocalVelNED);
}
/******************************************************************************/
@ -201,7 +213,8 @@ void FGState::Initialize(FGInitialCondition *FGIC)
{
float tht,psi,phi;
float U,V,W;
float U, V, W, h;
float latitude, longitude;
latitude = FGIC->GetLatitudeRadIC();
longitude = FGIC->GetLongitudeRadIC();
@ -226,12 +239,12 @@ bool FGState::StoreData(string fname)
datafile << (FDMExec->GetTranslation()->GetUVW())(1);
datafile << (FDMExec->GetTranslation()->GetUVW())(2);
datafile << (FDMExec->GetTranslation()->GetUVW())(3);
datafile << latitude;
datafile << longitude;
datafile << FDMExec->GetPosition()->GetLatitude();
datafile << FDMExec->GetPosition()->GetLongitude();
datafile << (FDMExec->GetRotation()->GetEuler())(1);
datafile << (FDMExec->GetRotation()->GetEuler())(2);
datafile << (FDMExec->GetRotation()->GetEuler())(3);
datafile << h;
datafile << FDMExec->GetPosition()->Geth();
datafile.close();
return true;
} else {
@ -262,7 +275,7 @@ float FGState::GetParameter(int val_idx)
{
switch(val_idx) {
case FG_QBAR:
return Getqbar();
return FDMExec->GetTranslation()->Getqbar();
case FG_WINGAREA:
return FDMExec->GetAircraft()->GetWingArea();
case FG_WINGSPAN:
@ -308,13 +321,13 @@ float FGState::GetParameter(int val_idx)
case FG_FLAPS_CMD:
return FDMExec->GetFCS()->GetDfCmd();
case FG_MACH:
return GetMach();
return FDMExec->GetTranslation()->GetMach();
case FG_ALTITUDE:
return Geth();
return FDMExec->GetPosition()->Geth();
case FG_BI2VEL:
return FDMExec->GetAircraft()->GetWingSpan()/(2.0 * GetVt());
return FDMExec->GetAircraft()->GetWingSpan()/(2.0 * FDMExec->GetTranslation()->GetVt());
case FG_CI2VEL:
return FDMExec->GetAircraft()->Getcbar()/(2.0 * GetVt());
return FDMExec->GetAircraft()->Getcbar()/(2.0 * FDMExec->GetTranslation()->GetVt());
}
return 0;
}

View file

@ -86,43 +86,24 @@ public:
void Initialize(FGInitialCondition *FGIC);
bool StoreData(string);
inline float GetVt(void) {return Vt;}
inline float Getlatitude(void) {return latitude;}
inline float Getlongitude(void) {return longitude;}
inline float GetGeodeticLat(void) {return GeodeticLat;}
inline float Getadot(void) {return adot;}
inline float Getbdot(void) {return bdot;}
inline float GetLocalAltitudeOverRunway(void) {return LocalAltitudeOverRunway;}
inline float Geth(void) {return h;}
inline float Geta(void) {return a;}
inline float GetMach(void) {return Mach;}
inline float Getsim_time(void) {return sim_time;}
inline float Getdt(void) {return dt;}
inline float Getqbar(void) {return qbar;}
float GetParameter(int val_idx);
float GetParameter(string val_string);
int GetParameterIndex(string val_string);
inline void SetVt(float tt) {Vt = tt;}
inline void Setlatitude(float tt) {latitude = tt;}
inline void Setlongitude(float tt) {longitude = tt;}
inline void SetGeodeticLat(float tt) {GeodeticLat = tt;}
inline void Setadot(float tt) {adot = tt;}
inline void Setbdot(float tt) {bdot = tt;}
inline void Setqbar(float tt) {qbar = tt;}
inline void SetLocalAltitudeOverRunway(float tt) {LocalAltitudeOverRunway = tt;}
inline void Seth(float tt) {h = tt;}
inline void Seta(float tt) {a = tt;}
inline void SetMach(float tt) {Mach = tt;}
inline float Setsim_time(float tt) {sim_time = tt; return sim_time;}
inline void Setdt(float tt) {dt = tt;}
@ -140,14 +121,9 @@ public:
private:
float Vt; // Total velocity
float latitude, longitude; // position
float GeodeticLat; // Geodetic Latitude
float adot, bdot; // alpha dot and beta dot
float h, a; // altitude above sea level, speed of sound
float qbar; // dynamic pressure
float a; // speed of sound
float sim_time, dt;
float Mach; // Mach number
FGFDMExec* FDMExec;
float LocalAltitudeOverRunway;

View file

@ -80,6 +80,11 @@ FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex),
vEuler(3)
{
Name = "FGTranslation";
qbar = 0;
Vt = 0.0;
Mach = 0.0;
alpha = beta = gamma = 0.0;
rho = 0.002378;
}
/******************************************************************************/
@ -123,11 +128,10 @@ bool FGTranslation::Run(void)
qbar = 0.5*rho*Vt*Vt;
mach = Vt / State->Geta();
Mach = Vt / State->Geta();
vlastUVWdot = vUVWdot;
PutState();
} else {
}
return false;
@ -148,12 +152,3 @@ void FGTranslation::GetState(void)
vEuler = Rotation->GetEuler();
}
/******************************************************************************/
void FGTranslation::PutState(void)
{
State->SetVt(Vt);
State->Setqbar(qbar);
State->SetMach(mach);
}

View file

@ -76,6 +76,8 @@ using namespace std;
CLASS DECLARATION
*******************************************************************************/
#pragma warn -8026
class FGTranslation : public FGModel
{
public:
@ -87,12 +89,17 @@ public:
inline float Getalpha(void) {return alpha;}
inline float Getbeta (void) {return beta; }
inline float Getgamma(void) {return gamma;}
inline float Getqbar (void) {return qbar;}
inline float GetVt (void) {return Vt;}
inline float GetMach (void) {return Mach;}
void SetUVW(FGColumnVector tt) {vUVW = tt;}
inline void Setalpha(float tt) {alpha = tt;}
inline void Setbeta (float tt) {beta = tt;}
inline void Setgamma(float tt) {gamma = tt;}
inline void Setqbar (float tt) {qbar = tt;}
inline void SetVt (float tt) {Vt = tt;}
inline void SetABG(float t1, float t2, float t3) {alpha=t1; beta=t2; gamma=t3;}
@ -105,14 +112,14 @@ private:
FGColumnVector vPQR;
FGColumnVector vForces;
FGColumnVector vEuler;
float Vt, qbar, mach;
float Vt, qbar, Mach;
float Mass, dt;
float alpha, beta, gamma;
float rho;
void GetState(void);
void PutState(void);
};
#pragma warn .8026
/******************************************************************************/
#endif

View file

@ -78,16 +78,4 @@ FGUtility::FGUtility()
FGUtility::~FGUtility()
{
}
float FGUtility::ToGeodetic()
{
return 0.0;
}
float FGUtility:: FromGeodetic()
{
return 0.0;
}

View file

@ -59,9 +59,6 @@ public:
FGUtility(void);
~FGUtility(void);
float ToGeodetic(void);
float FromGeodetic(void);
protected:
private:

View file

@ -131,10 +131,8 @@ void FGfdmSocket::Append(long item)
void FGfdmSocket::Send(void)
{
int len;
buffer += string("\n");
if ((len = send(sckt,buffer.c_str(),buffer.size(),0)) <= 0) {
if ((send(sckt,buffer.c_str(),buffer.size(),0)) <= 0) {
perror("send");
} else {
}