-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
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;
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;
}
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;
soundspeed = sqrt(SHRatio*Reng*temperature);
State->Seta(soundspeed);
+
+ if (debug_lvl > 1) Debug();
+
} else { // skip Run() execution this time
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//
+// See reference 1
void FGAtmosphere::Calculate(double altitude)
{
- //see reference [1]
+ double slope, reftemp, refpress;
+ int i = 0;
+ bool lookup = false;
- double slope,reftemp,refpress;
- int i=0; bool lookup = false;
- // cout << "Atmosphere: h=" << altitude << " rho= " << density << endl;
- i=lastIndex;
- if(altitude < htab[lastIndex]) {
+ 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--; }
+ i = lastIndex-1;
+ 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++; }
+ i = lastIndex+1;
+ while(htab[i+1] < altitude) i++;
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+void FGAtmosphere::Turbulence(void)
+{
+ 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)
{
- //TODO: Add your source code here
+ 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;
+ }
}
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];
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);
};
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;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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;
}
if (model_iterator == 0L) break;
}
- Frame++;
+ frame = Frame++;
State->IncrTime();
return true;
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;
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;
FG_PITCHRATE,
FG_ROLLRATE,
FG_YAWRATE,
+ FG_AEROP,
+ FG_AEROQ,
+ FG_AEROR,
FG_CL_SQRD,
FG_MACH,
FG_ALTITUDE,
virtual void Debug(void) {};
static short debug_lvl;
- static int frame;
+ static unsigned int frame;
static unsigned int messageId;
static const double radtodeg;
}
Type = etPiston;
+ crank_counter = 0;
EngineNumber = 0; // FIXME: this should be the actual number
OilTemp_degK = 298; // FIXME: should be initialized in FGEngine
// (spark, fuel, starter motor etc)
bool spark;
bool fuel;
- static int crank_counter = 0;
// Check for spark
Magneto_Left = false;
double GetPowerAvailable(void) {return PowerAvailable;}
private:
+ int crank_counter;
+
double BrakeHorsePower;
double SpeedSlope;
double SpeedIntercept;
# endif
#endif
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#endif
+
#include "FGState.h"
static const char *IdSrc = "$Id$";
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 " );
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());
typedef enum { tLongitudinal, tFull, tGround, tCustom, tNone } TrimMode;
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#endif
+
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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 \
-/* 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
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 {
// 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 {