![]() |
JSBSim Flight Dynamics Model 1.0 (23 February 2013)
An Open Source Flight Dynamics and Control Software Library in C++
|
JSBSim Base class. More...
#include <FGJSBBase.h>
Inheritance diagram for FGJSBBase:
Collaboration diagram for FGJSBBase:Classes | |
| class | Filter |
| First order, (low pass / lag) filter. More... | |
| class | Message |
| JSBSim Message structure. More... | |
Public Types | |
| enum | { eL = 1, eM, eN } |
Moments L, M, N. | |
| enum | { eP = 1, eQ, eR } |
Rates P, Q, R. | |
| enum | { eU = 1, eV, eW } |
Velocities U, V, W. | |
| enum | { eX = 1, eY, eZ } |
Positions X, Y, Z. | |
| enum | { ePhi = 1, eTht, ePsi } |
Euler angles Phi, Theta, Psi. | |
| enum | { eDrag = 1, eSide, eLift } |
Stability axis forces, Drag, Side force, Lift. | |
| enum | { eRoll = 1, ePitch, eYaw } |
Local frame orientation Roll, Pitch, Yaw. | |
| enum | { eNorth = 1, eEast, eDown } |
Local frame position North, East, Down. | |
| enum | { eLat = 1, eLong, eRad } |
Locations Radius, Latitude, Longitude. | |
| enum | { inNone = 0, inDegrees, inRadians, inMeters, inFeet } |
Conversion specifiers. | |
Public Member Functions | |
| FGJSBBase () | |
| Constructor for FGJSBBase. | |
| virtual | ~FGJSBBase () |
| Destructor for FGJSBBase. | |
| void | disableHighLighting (void) |
| Disables highlighting in the console output. | |
| std::string | GetVersion (void) |
| Returns the version number of JSBSim. | |
JSBSim Messaging functions | |
| void | PutMessage (const Message &msg) |
| Places a Message structure on the Message queue. | |
| void | PutMessage (const std::string &text) |
| Creates a message with the given text and places it on the queue. | |
| void | PutMessage (const std::string &text, bool bVal) |
| Creates a message with the given text and boolean value and places it on the queue. | |
| void | PutMessage (const std::string &text, int iVal) |
| Creates a message with the given text and integer value and places it on the queue. | |
| void | PutMessage (const std::string &text, double dVal) |
| Creates a message with the given text and double value and places it on the queue. | |
| int | SomeMessages (void) |
| Reads the message on the queue (but does not delete it). | |
| void | ProcessMessage (void) |
| Reads the message on the queue and removes it from the queue. | |
| Message * | ProcessNextMessage (void) |
| Reads the next message on the queue and removes it from the queue. | |
Static Public Member Functions | |
| static double | CelsiusToFahrenheit (double celsius) |
| Converts from degrees Celsius to degrees Fahrenheit. | |
| static double | CelsiusToKelvin (double celsius) |
| Converts from degrees Celsius to degrees Kelvin. | |
| static double | CelsiusToRankine (double celsius) |
| Converts from degrees Celsius to degrees Rankine. | |
| static double | Constrain (double min, double value, double max) |
| Constrain a value between a minimum and a maximum value. | |
| static bool | EqualToRoundoff (double a, float b) |
| Finite precision comparison. | |
| static bool | EqualToRoundoff (double a, double b) |
| Finite precision comparison. | |
| static bool | EqualToRoundoff (float a, float b) |
| Finite precision comparison. | |
| static bool | EqualToRoundoff (float a, double b) |
| Finite precision comparison. | |
| static double | FahrenheitToCelsius (double fahrenheit) |
| Converts from degrees Fahrenheit to degrees Celsius. | |
| static double | KelvinToCelsius (double kelvin) |
| Converts from degrees Kelvin to degrees Celsius. | |
| static double | KelvinToFahrenheit (double kelvin) |
| Converts from degrees Kelvin to degrees Fahrenheit. | |
| static double | KelvinToRankine (double kelvin) |
| Converts from degrees Kelvin to degrees Rankine. | |
| static double | MachFromVcalibrated (double vcas, double p, double psl, double rhosl) |
| Calculate the Mach number from the calibrated airspeed. | |
| static double | RankineToCelsius (double rankine) |
| Converts from degrees Rankine to degrees Celsius. | |
| static double | RankineToKelvin (double rankine) |
| Converts from degrees Rankine to degrees Kelvin. | |
| static double | sign (double num) |
| static double | VcalibratedFromMach (double mach, double p, double psl, double rhosl) |
| Calculate the calibrated airspeed from the Mach number. | |
Static Public Attributes | |
| static short | debug_lvl = 1 |
JSBSim console output highlighting terms. | |
| static char | highint [5] = {27, '[', '1', 'm', '\0' } |
| highlights text | |
| static char | halfint [5] = {27, '[', '2', 'm', '\0' } |
| low intensity text | |
| static char | normint [6] = {27, '[', '2', '2', 'm', '\0' } |
| normal intensity text | |
| static char | reset [5] = {27, '[', '0', 'm', '\0' } |
| resets text properties | |
| static char | underon [5] = {27, '[', '4', 'm', '\0' } |
| underlines text | |
| static char | underoff [6] = {27, '[', '2', '4', 'm', '\0' } |
| underline off | |
| static char | fgblue [6] = {27, '[', '3', '4', 'm', '\0' } |
| blue text | |
| static char | fgcyan [6] = {27, '[', '3', '6', 'm', '\0' } |
| cyan text | |
| static char | fgred [6] = {27, '[', '3', '1', 'm', '\0' } |
| red text | |
| static char | fggreen [6] = {27, '[', '3', '2', 'm', '\0' } |
| green text | |
| static char | fgdef [6] = {27, '[', '3', '9', 'm', '\0' } |
| default text | |
Protected Member Functions | |
| void | Debug (int) |
Static Protected Member Functions | |
| static std::string | CreateIndexedPropertyName (const std::string &Property, int index) |
| static double | GaussianRandomNumber (void) |
Static Protected Attributes | |
| static const double | degtorad = 0.017453292519943295769236907684886 |
| static const double | fpstokts = 0.592484 |
| static const double | fttom = 0.3048 |
| static const double | hptoftlbssec = 550.0 |
| static const double | in3tom3 = 1.638706E-5 |
| static const double | inchtoft = 0.08333333 |
| static const double | inhgtopa = 3386.38 |
| static const std::string | JSBSim_version = " " __TIME__ |
| static const double | kgtolb = 2.20462 |
| static const double | kgtoslug = 0.06852168 |
| static const double | ktstofps = 1.68781 |
| static const double | lbtoslug = 1.0/slugtolb |
| static Message | localMsg |
| static const double | m3toft3 = 1.0/(fttom*fttom*fttom) |
| static double | Mair = 28.9645 |
| static unsigned int | messageId = 0 |
| static std::queue< Message > | Messages |
| static const std::string | needed_cfg_version = "2.0" |
| static const double | psftoinhg = 0.014138 |
| static const double | psftopa = 47.88 |
| static const double | radtodeg = 57.295779513082320876798154814105 |
| static double | Reng = 1716.56 |
| static double | Rstar = 1545.348 |
| static const double | SHRatio = 1.40 |
| static const double | slugtolb = 32.174049 |
This class provides universal constants, utility functions, messaging functions, and enumerated constants to JSBSim.
Definition at line 82 of file FGJSBBase.h.
| static double CelsiusToFahrenheit | ( | double | celsius | ) | [inline, static] |
| celsius | The temperature in degrees Celsius. |
Definition at line 241 of file FGJSBBase.h.
Referenced by FGTank::GetTemperature().
{
return celsius * 1.8 + 32.0;
}
Here is the caller graph for this function:| static double CelsiusToKelvin | ( | double | celsius | ) | [inline, static] |
| celsius | The temperature in degrees Celsius. |
Definition at line 248 of file FGJSBBase.h.
{
return celsius + 273.15;
}
| static double CelsiusToRankine | ( | double | celsius | ) | [inline, static] |
| celsius | The temperature in degrees Celsius. |
Definition at line 206 of file FGJSBBase.h.
{
return celsius * 1.8 + 491.67;
}
| static bool EqualToRoundoff | ( | double | a, |
| double | b | ||
| ) | [inline, static] |
| a | first value to compare |
| b | second value to compare |
Definition at line 286 of file FGJSBBase.h.
Referenced by FGJSBBase::EqualToRoundoff(), and FGKinemat::Run().
{
double eps = 2.0*DBL_EPSILON;
return std::fabs(a - b) <= eps * max(std::fabs(a), std::fabs(b));
}
Here is the caller graph for this function:| static bool EqualToRoundoff | ( | float | a, |
| float | b | ||
| ) | [inline, static] |
| a | first value to compare |
| b | second value to compare |
Definition at line 295 of file FGJSBBase.h.
{
float eps = 2.0*FLT_EPSILON;
return std::fabs(a - b) <= eps * max(std::fabs(a), std::fabs(b));
}
| static bool EqualToRoundoff | ( | double | a, |
| float | b | ||
| ) | [inline, static] |
| a | first value to compare |
| b | second value to compare |
Definition at line 312 of file FGJSBBase.h.
References FGJSBBase::EqualToRoundoff().
{
return EqualToRoundoff((float)a, b);
}
Here is the call graph for this function:| static bool EqualToRoundoff | ( | float | a, |
| double | b | ||
| ) | [inline, static] |
| a | first value to compare |
| b | second value to compare |
Definition at line 304 of file FGJSBBase.h.
References FGJSBBase::EqualToRoundoff().
{
return EqualToRoundoff(a, (float)b);
}
Here is the call graph for this function:| static double FahrenheitToCelsius | ( | double | fahrenheit | ) | [inline, static] |
| fahrenheit | The temperature in degrees Fahrenheit. |
Definition at line 234 of file FGJSBBase.h.
Referenced by FGTank::FGTank().
{
return (fahrenheit - 32.0)/1.8;
}
Here is the caller graph for this function:| std::string GetVersion | ( | void | ) | [inline] |
Definition at line 189 of file FGJSBBase.h.
{return JSBSim_version;}
| static double KelvinToCelsius | ( | double | kelvin | ) | [inline, static] |
| celsius | The temperature in degrees Kelvin. |
Definition at line 255 of file FGJSBBase.h.
{
return kelvin - 273.15;
}
| static double KelvinToFahrenheit | ( | double | kelvin | ) | [inline, static] |
| kelvin | The temperature in degrees Kelvin. |
Definition at line 199 of file FGJSBBase.h.
{
return 1.8*kelvin - 459.4;
}
| static double KelvinToRankine | ( | double | kelvin | ) | [inline, static] |
| kelvin | The temperature in degrees Kelvin. |
Definition at line 220 of file FGJSBBase.h.
{
return kelvin * 1.8;
}
| double MachFromVcalibrated | ( | double | vcas, |
| double | p, | ||
| double | psl, | ||
| double | rhosl | ||
| ) | [static] |
For subsonic speeds, the reversed formula has a closed form. For supersonic speeds, the Rayleigh formula is reversed by the Newton-Raphson algorithm.
| vcas | The calibrated airspeed (CAS) in ft/s |
| p | Pressure in psf |
| psl | Pressure at sea level in psf |
| rhosl | Density at sea level in slugs/ft^3 |
Definition at line 318 of file FGJSBBase.cpp.
Referenced by FGInitialCondition::SetAltitudeASLFtIC(), and FGInitialCondition::SetVcalibratedKtsIC().
{
double pt = p + psl*(pow(1+vcas*vcas*rhosl/(7.0*psl),3.5)-1);
if (pt/p < 1.89293)
return sqrt(5.0*(pow(pt/p, 0.2857143) -1)); // Mach < 1
else {
// Mach >= 1
double mach = sqrt(0.77666*pt/p); // Initial guess is based on a quadratic approximation of the Rayleigh formula
double delta = 1.;
double target = pt/(166.92158*p);
int iter = 0;
// Find the root with Newton-Raphson. Since the differential is never zero,
// the function is monotonic and has only one root with a multiplicity of one.
// Convergence is certain.
while (delta > 1E-5 && iter < 10) {
double m2 = mach*mach; // Mach^2
double m6 = m2*m2*m2; // Mach^6
delta = mach*m6/pow(7.0*m2-1.0,2.5) - target;
double diff = 7.0*m6*(2.0*m2-1)/pow(7.0*m2-1.0,3.5); // Never zero when Mach >= 1
mach -= delta/diff;
iter++;
}
return mach;
}
}
Here is the caller graph for this function:| void ProcessMessage | ( | void | ) |
This function also prints out the message.
Definition at line 188 of file FGJSBBase.cpp.
{
if (Messages.empty()) return;
localMsg = Messages.front();
while (Messages.size() > 0) {
switch (localMsg.type) {
case JSBSim::FGJSBBase::Message::eText:
cout << localMsg.messageId << ": " << localMsg.text << endl;
break;
case JSBSim::FGJSBBase::Message::eBool:
cout << localMsg.messageId << ": " << localMsg.text << " " << localMsg.bVal << endl;
break;
case JSBSim::FGJSBBase::Message::eInteger:
cout << localMsg.messageId << ": " << localMsg.text << " " << localMsg.iVal << endl;
break;
case JSBSim::FGJSBBase::Message::eDouble:
cout << localMsg.messageId << ": " << localMsg.text << " " << localMsg.dVal << endl;
break;
default:
cerr << "Unrecognized message type." << endl;
break;
}
Messages.pop();
if (Messages.size() > 0) localMsg = Messages.front();
else break;
}
}
| FGJSBBase::Message * ProcessNextMessage | ( | void | ) |
This function also prints out the message.
Definition at line 220 of file FGJSBBase.cpp.
{
if (Messages.empty()) return NULL;
localMsg = Messages.front();
Messages.pop();
return &localMsg;
}
| void PutMessage | ( | const std::string & | text, |
| bool | bVal | ||
| ) |
| text | message text |
| bVal | boolean value associated with the message |
Definition at line 142 of file FGJSBBase.cpp.
{
Message msg;
msg.text = text;
msg.messageId = messageId++;
msg.subsystem = "FDM";
msg.type = Message::eBool;
msg.bVal = bVal;
Messages.push(msg);
}
| void PutMessage | ( | const std::string & | text, |
| int | iVal | ||
| ) |
| text | message text |
| iVal | integer value associated with the message |
Definition at line 155 of file FGJSBBase.cpp.
{
Message msg;
msg.text = text;
msg.messageId = messageId++;
msg.subsystem = "FDM";
msg.type = Message::eInteger;
msg.iVal = iVal;
Messages.push(msg);
}
| void PutMessage | ( | const std::string & | text | ) |
| text | message text |
Definition at line 130 of file FGJSBBase.cpp.
{
Message msg;
msg.text = text;
msg.messageId = messageId++;
msg.subsystem = "FDM";
msg.type = Message::eText;
Messages.push(msg);
}
| void PutMessage | ( | const Message & | msg | ) |
| msg | pointer to a Message structure |
Definition at line 123 of file FGJSBBase.cpp.
{
Messages.push(msg);
}
| void PutMessage | ( | const std::string & | text, |
| double | dVal | ||
| ) |
| text | message text |
| dVal | double value associated with the message |
Definition at line 168 of file FGJSBBase.cpp.
{
Message msg;
msg.text = text;
msg.messageId = messageId++;
msg.subsystem = "FDM";
msg.type = Message::eDouble;
msg.dVal = dVal;
Messages.push(msg);
}
| static double RankineToCelsius | ( | double | rankine | ) | [inline, static] |
| rankine | The temperature in degrees Rankine. |
Definition at line 213 of file FGJSBBase.h.
Referenced by FGAuxiliary::FGAuxiliary(), and FGAuxiliary::Run().
{
return (rankine - 491.67)/1.8;
}
Here is the caller graph for this function:| static double RankineToKelvin | ( | double | rankine | ) | [inline, static] |
| rankine | The temperature in degrees Rankine. |
Definition at line 227 of file FGJSBBase.h.
Referenced by FGPiston::Calculate(), and FGPiston::ResetToIC().
{
return rankine/1.8;
}
Here is the caller graph for this function:| int SomeMessages | ( | void | ) |
Definition at line 181 of file FGJSBBase.cpp.
{
return !Messages.empty();
}
| double VcalibratedFromMach | ( | double | mach, |
| double | p, | ||
| double | psl, | ||
| double | rhosl | ||
| ) | [static] |
It uses the Rayleigh formula for supersonic speeds (See "Introduction to Aerodynamics of a Compressible Fluid - H.W. Liepmann, A.E. Puckett - Wiley & sons (1947)" ยง5.4 pp 75-80)
| mach | The Mach number |
| p | Pressure in psf |
| psl | Pressure at sea level in psf |
| rhosl | Density at sea level in slugs/ft^3 |
Definition at line 286 of file FGJSBBase.cpp.
Referenced by FGInitialCondition::GetVcalibratedKtsIC(), and FGInitialCondition::SetAltitudeASLFtIC().
{
double pt,A;
if (mach < 0) mach=0;
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 of
// the normal shock assumption should not be a bad one -- most supersonic
// aircraft place the pitot probe out front so that it is the forward
// most point on the aircraft. The real shock would, of course, take
// on something like the shape of a rounded-off cone but, here again,
// the assumption should be good since the opening of the pitot probe
// is very small and, therefore, the effects of the shock curvature
// should be small as well. AFAIK, this approach is fairly well accepted
// within the aerospace community
// The denominator below is zero for Mach ~ 0.38, for which
// we'll never be here, so we're safe
pt = p*166.92158*pow(mach,7.0)/pow(7*mach*mach-1,2.5);
}
A = pow(((pt-p)/psl+1),0.28571);
return sqrt(7*psl/rhosl*(A-1));
}
Here is the caller graph for this function: