Sync with latest JSBSim CVS.
This commit is contained in:
parent
d19ef5cd99
commit
ac50500e80
15 changed files with 143 additions and 29 deletions
2
aclocal.m4
vendored
2
aclocal.m4
vendored
|
@ -1,4 +1,4 @@
|
|||
dnl aclocal.m4 generated automatically by aclocal 1.4
|
||||
dnl aclocal.m4 generated automatically by aclocal 1.4-p4
|
||||
|
||||
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
|
|
|
@ -69,7 +69,14 @@ CLASS IMPLEMENTATION
|
|||
|
||||
|
||||
FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex),
|
||||
vWindNED(3)
|
||||
vWindNED(3),
|
||||
vDirectiondAccelDt(3),
|
||||
vDirectionAccel(3),
|
||||
vDirection(3),
|
||||
vTurbulence(3),
|
||||
vTurbulenceGrad(3),
|
||||
vBodyTurbGrad(3),
|
||||
vTurbPQR(3)
|
||||
{
|
||||
Name = "FGAtmosphere";
|
||||
lastIndex=0;
|
||||
|
@ -83,6 +90,11 @@ FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex),
|
|||
htab[6]=200131.234;
|
||||
htab[7]=259186.352; //ft.
|
||||
|
||||
MagnitudedAccelDt = MagnitudeAccel = Magnitude = 0.0;
|
||||
// turbType = ttNone;
|
||||
turbType = ttBerndt; // temporarily disable turbulence until fully tested
|
||||
TurbGain = 100.0;
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;
|
||||
}
|
||||
|
||||
|
@ -128,6 +140,11 @@ bool FGAtmosphere::Run(void)
|
|||
temperature = exTemperature;
|
||||
}
|
||||
|
||||
if (turbType != ttNone) {
|
||||
Turbulence();
|
||||
vWindNED += vTurbulence;
|
||||
}
|
||||
|
||||
if (vWindNED(1) != 0.0) psiw = atan2( vWindNED(2), vWindNED(1) );
|
||||
|
||||
if (psiw < 0) psiw += 2*M_PI;
|
||||
|
@ -135,6 +152,9 @@ bool FGAtmosphere::Run(void)
|
|||
soundspeed = sqrt(SHRatio*Reng*temperature);
|
||||
|
||||
State->Seta(soundspeed);
|
||||
|
||||
if (debug_lvl > 1) Debug();
|
||||
|
||||
} else { // skip Run() execution this time
|
||||
}
|
||||
|
||||
|
@ -142,28 +162,31 @@ bool FGAtmosphere::Run(void)
|
|||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//
|
||||
// See reference 1
|
||||
|
||||
void FGAtmosphere::Calculate(double altitude)
|
||||
{
|
||||
//see reference [1]
|
||||
|
||||
double slope, reftemp, refpress;
|
||||
int i=0; bool lookup = false;
|
||||
// cout << "Atmosphere: h=" << altitude << " rho= " << density << endl;
|
||||
int i = 0;
|
||||
bool lookup = false;
|
||||
|
||||
i = lastIndex;
|
||||
if (altitude < htab[lastIndex]) {
|
||||
if (altitude <= 0) {
|
||||
i=0; altitude=0;
|
||||
i = 0;
|
||||
altitude=0;
|
||||
} else {
|
||||
i = lastIndex-1;
|
||||
while (htab[i] > altitude) { i--; }
|
||||
while (htab[i] > altitude) i--;
|
||||
}
|
||||
} else if (altitude > htab[lastIndex+1]){
|
||||
if (altitude >= htab[7]){
|
||||
i = 7; altitude = htab[7];
|
||||
i = 7;
|
||||
altitude = htab[7];
|
||||
} else {
|
||||
i = lastIndex+1;
|
||||
while(htab[i+1] < altitude) { i++; }
|
||||
while(htab[i+1] < altitude) i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,8 +258,57 @@ void FGAtmosphere::Calculate(double altitude)
|
|||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGAtmosphere::Debug(void)
|
||||
void FGAtmosphere::Turbulence(void)
|
||||
{
|
||||
//TODO: Add your source code here
|
||||
switch (turbType) {
|
||||
case ttBerndt:
|
||||
vDirectiondAccelDt(eX) = 1 - 2.0*(((double)(rand()))/RAND_MAX);
|
||||
vDirectiondAccelDt(eY) = 1 - 2.0*(((double)(rand()))/RAND_MAX);
|
||||
vDirectiondAccelDt(eZ) = 1 - 2.0*(((double)(rand()))/RAND_MAX);
|
||||
|
||||
MagnitudedAccelDt = 1 - 2.0*(((double)(rand()))/RAND_MAX);
|
||||
MagnitudeAccel += MagnitudedAccelDt*rate*State->Getdt();
|
||||
Magnitude += MagnitudeAccel*rate*State->Getdt();
|
||||
|
||||
vDirectiondAccelDt.Normalize();
|
||||
vDirectionAccel += vDirectiondAccelDt*rate*State->Getdt();
|
||||
vDirectionAccel.Normalize();
|
||||
vDirection += vDirectionAccel*rate*State->Getdt();
|
||||
vDirection.Normalize();
|
||||
|
||||
vTurbulence = TurbGain*Magnitude * vDirection;
|
||||
vTurbulenceGrad = TurbGain*MagnitudeAccel * vDirection;
|
||||
|
||||
vBodyTurbGrad = State->GetTl2b()*vTurbulenceGrad;
|
||||
vTurbPQR(eP) = vBodyTurbGrad(eY)/Aircraft->GetWingSpan();
|
||||
if (Aircraft->GetHTailArm() != 0.0)
|
||||
vTurbPQR(eQ) = vBodyTurbGrad(eZ)/Aircraft->GetHTailArm();
|
||||
else
|
||||
vTurbPQR(eQ) = vBodyTurbGrad(eZ)/10.0;
|
||||
|
||||
if (Aircraft->GetVTailArm())
|
||||
vTurbPQR(eR) = vBodyTurbGrad(eX)/Aircraft->GetVTailArm();
|
||||
else
|
||||
vTurbPQR(eR) = vBodyTurbGrad(eX)/10.0;
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGAtmosphere::Debug(void)
|
||||
{
|
||||
if (frame == 0) {
|
||||
cout << "vTurbulence(X), vTurbulence(Y), vTurbulence(Z), "
|
||||
<< "vTurbulenceGrad(X), vTurbulenceGrad(Y), vTurbulenceGrad(Z), "
|
||||
<< "vDirection(X), vDirection(Y), vDirection(Z), "
|
||||
<< "Magnitude, "
|
||||
<< "vTurbPQR(P), vTurbPQR(Q), vTurbPQR(R), " << endl;
|
||||
} else {
|
||||
cout << vTurbulence << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,9 +142,15 @@ public:
|
|||
increases counterclockwise. The wind heading is returned in radians.*/
|
||||
inline double GetWindPsi(void) { return psiw; }
|
||||
|
||||
inline void SetTurbGain(double tt) {TurbGain = tt;}
|
||||
|
||||
inline double GetTurbPQR(int idx) {return vTurbPQR(idx);}
|
||||
|
||||
private:
|
||||
double rho;
|
||||
|
||||
enum tType {ttBerndt, ttNone} turbType;
|
||||
|
||||
int lastIndex;
|
||||
double h;
|
||||
double htab[8];
|
||||
|
@ -154,10 +160,21 @@ private:
|
|||
bool useExternal;
|
||||
double exTemperature,exDensity,exPressure;
|
||||
|
||||
double MagnitudedAccelDt, MagnitudeAccel, Magnitude;
|
||||
double TurbGain;
|
||||
FGColumnVector3 vDirectiondAccelDt;
|
||||
FGColumnVector3 vDirectionAccel;
|
||||
FGColumnVector3 vDirection;
|
||||
FGColumnVector3 vTurbulence;
|
||||
FGColumnVector3 vTurbulenceGrad;
|
||||
FGColumnVector3 vBodyTurbGrad;
|
||||
FGColumnVector3 vTurbPQR;
|
||||
|
||||
FGColumnVector3 vWindNED;
|
||||
double psiw;
|
||||
|
||||
void Calculate(double altitude);
|
||||
void Turbulence(void);
|
||||
void Debug(void);
|
||||
};
|
||||
|
||||
|
|
|
@ -32,8 +32,9 @@ CLASS IMPLEMENTATION
|
|||
FGColumnVector3::FGColumnVector3(void)
|
||||
{
|
||||
rowCtr = 1;
|
||||
//cout << "Allocated: " << data << endl;
|
||||
//if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
|
||||
data[0]=0; data[1]=0; data[2]=0; data[3]=0;
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -41,16 +42,15 @@ FGColumnVector3::FGColumnVector3(void)
|
|||
FGColumnVector3::FGColumnVector3(int m)
|
||||
{
|
||||
rowCtr = 1;
|
||||
data[1]=0;data[2]=0;data[3]=0;
|
||||
//cout << "Allocated: " << data << endl;
|
||||
//if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
|
||||
data[0]=0; data[1]=0; data[2]=0; data[3]=0;
|
||||
|
||||
if (debug_lvl & 2) cout << "Instantiated: FGColumnVector3" << endl;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
FGColumnVector3::~FGColumnVector3(void)
|
||||
{
|
||||
//cout << "Freed: " << data << endl;
|
||||
if (debug_lvl & 2) cout << "Destroyed: FGColumnVector3" << endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ bool FGFDMExec::Run(void)
|
|||
if (model_iterator == 0L) break;
|
||||
}
|
||||
|
||||
Frame++;
|
||||
frame = Frame++;
|
||||
State->IncrTime();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -664,7 +664,8 @@ bool FGInitialCondition::solve(double *y,double x)
|
|||
i=0;
|
||||
while ((fabs(d) > eps) && (i < 100)) {
|
||||
d=(x3-x1)/d0;
|
||||
x2=x1-d*d0*f1/(f3-f1);
|
||||
if (f3-f1 != 0.0) x2 = x1-d*d0*f1/(f3-f1);
|
||||
else x2 = x1-d*d0*f1/0.01; // TONY: What is correct? This is a WAG.
|
||||
|
||||
f2=(this->*sfunc)(x2)-x;
|
||||
//cout << "solve x1,x2,x3: " << x1 << "," << x2 << "," << x3 << endl;
|
||||
|
|
|
@ -70,6 +70,7 @@ const string FGJSBBase::JSBSim_version = "0.9.1";
|
|||
queue <struct FGJSBBase::Message*> FGJSBBase::Messages;
|
||||
struct FGJSBBase::Message FGJSBBase::localMsg;
|
||||
unsigned int FGJSBBase::messageId = 0;
|
||||
unsigned int FGJSBBase::frame = 0;
|
||||
|
||||
short FGJSBBase::debug_lvl = 0;
|
||||
|
||||
|
|
|
@ -94,6 +94,9 @@ enum eParam {
|
|||
FG_PITCHRATE,
|
||||
FG_ROLLRATE,
|
||||
FG_YAWRATE,
|
||||
FG_AEROP,
|
||||
FG_AEROQ,
|
||||
FG_AEROR,
|
||||
FG_CL_SQRD,
|
||||
FG_MACH,
|
||||
FG_ALTITUDE,
|
||||
|
@ -260,7 +263,7 @@ protected:
|
|||
virtual void Debug(void) {};
|
||||
|
||||
static short debug_lvl;
|
||||
static int frame;
|
||||
static unsigned int frame;
|
||||
static unsigned int messageId;
|
||||
|
||||
static const double radtodeg;
|
||||
|
|
|
@ -96,6 +96,7 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg)
|
|||
}
|
||||
|
||||
Type = etPiston;
|
||||
crank_counter = 0;
|
||||
EngineNumber = 0; // FIXME: this should be the actual number
|
||||
OilTemp_degK = 298; // FIXME: should be initialized in FGEngine
|
||||
|
||||
|
@ -211,7 +212,6 @@ void FGPiston::doEngineStartup(void)
|
|||
// (spark, fuel, starter motor etc)
|
||||
bool spark;
|
||||
bool fuel;
|
||||
static int crank_counter = 0;
|
||||
|
||||
// Check for spark
|
||||
Magneto_Left = false;
|
||||
|
|
|
@ -88,6 +88,8 @@ public:
|
|||
double GetPowerAvailable(void) {return PowerAvailable;}
|
||||
|
||||
private:
|
||||
int crank_counter;
|
||||
|
||||
double BrakeHorsePower;
|
||||
double SpeedSlope;
|
||||
double SpeedIntercept;
|
||||
|
|
|
@ -47,6 +47,10 @@ INCLUDES
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#include "FGState.h"
|
||||
|
||||
static const char *IdSrc = "$Id$";
|
||||
|
@ -115,6 +119,9 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
|
|||
RegisterVariable(FG_PITCHRATE, " pitch_rate " );
|
||||
RegisterVariable(FG_ROLLRATE, " roll_rate " );
|
||||
RegisterVariable(FG_YAWRATE, " yaw_rate " );
|
||||
RegisterVariable(FG_AEROQ, " aero_pitch_rate ");
|
||||
RegisterVariable(FG_AEROP, " aero_roll_rate " );
|
||||
RegisterVariable(FG_AEROR, " aero_yaw_rate " );
|
||||
RegisterVariable(FG_CL_SQRD, " Clift_sqrd " );
|
||||
RegisterVariable(FG_MACH, " mach " );
|
||||
RegisterVariable(FG_ALTITUDE, " altitude " );
|
||||
|
@ -216,6 +223,12 @@ double FGState::GetParameter(eParam val_idx) {
|
|||
return Rotation->GetPQR(eP);
|
||||
case FG_YAWRATE:
|
||||
return Rotation->GetPQR(eR);
|
||||
case FG_AEROQ:
|
||||
return Rotation->GetPQR(eQ) + Atmosphere->GetTurbPQR(eQ); // add aero turbulence effects
|
||||
case FG_AEROP:
|
||||
return Rotation->GetPQR(eP) + Atmosphere->GetTurbPQR(eP); // add aero turbulence effects
|
||||
case FG_AEROR:
|
||||
return Rotation->GetPQR(eR) + Atmosphere->GetTurbPQR(eR); // add aero turbulence effects
|
||||
case FG_CL_SQRD:
|
||||
if (Translation->Getqbar() > 0.00)
|
||||
scratch = Aerodynamics->GetvLastFs(eLift)/(Aircraft->GetWingArea()*Translation->Getqbar());
|
||||
|
|
|
@ -72,6 +72,10 @@ DEFINITIONS
|
|||
|
||||
typedef enum { tLongitudinal, tFull, tGround, tCustom, tNone } TrimMode;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
FORWARD DECLARATIONS
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||
|
|
|
@ -6,6 +6,7 @@ libFlight_a_SOURCES = \
|
|||
ADA.cxx ADA.hxx \
|
||||
Balloon.cxx Balloon.h \
|
||||
External.cxx External.hxx \
|
||||
ExternalNet.cxx ExternalNet.hxx \
|
||||
flight.cxx flight.hxx \
|
||||
IO360.cxx IO360.hxx \
|
||||
JSBSim.cxx JSBSim.hxx \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* src/Include/config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
/* src/Include/config.h.in. Generated automatically from configure.in by autoheader 2.13. */
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef const
|
||||
|
|
|
@ -211,7 +211,7 @@ FGFX::update ()
|
|||
|
||||
float rel_wind = cur_fdm_state->get_V_rel_wind(); // FPS
|
||||
if (rel_wind > 60.0) { // a little off 30kt
|
||||
float volume = rel_wind/1200.0; // FIXME!!!
|
||||
float volume = rel_wind/600.0; // FIXME!!!
|
||||
_wind->set_volume(volume);
|
||||
set_playing("wind", true);
|
||||
} else {
|
||||
|
@ -273,7 +273,7 @@ FGFX::update ()
|
|||
// if the velocity is under 6kt.
|
||||
double speed = cur_fdm_state->get_V_equiv_kts();
|
||||
if (gearOnGround > 0 && speed >= 6.0) {
|
||||
double volume = (gearOnGround/totalGear) * (speed/60.0);
|
||||
double volume = 2.0 * (gearOnGround/totalGear) * (speed/60.0);
|
||||
_rumble->set_volume(volume);
|
||||
set_playing("rumble", true);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue