JSBSim Flight Dynamics Model
1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
|
Encapsulates the JSBSim simulation executive. More...
#include <FGFDMExec.h>
Classes | |
struct | PropertyCatalogStructure |
Public Types | |
enum | eModels { ePropagate =0, eInput, eInertial, eAtmosphere, eWinds, eSystems, eMassBalance, eAuxiliary, ePropulsion, eAerodynamics, eGroundReactions, eExternalReactions, eBuoyantForces, eAircraft, eAccelerations, eOutput, eNumStandardModels } |
Public Types inherited from FGJSBBase | |
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 | |
FGFDMExec (FGPropertyManager *root=0, unsigned int *fdmctr=0) | |
Default constructor. | |
~FGFDMExec () | |
Default destructor. | |
void | BuildPropertyCatalog (struct PropertyCatalogStructure *pcs) |
Builds a catalog of properties. More... | |
void | CheckIncrementalHold (void) |
Checks if required to hold afer increment. | |
void | DisableOutput (void) |
Disables data logging to all outputs. | |
void | DoTrim (int mode) |
Executes trimming in the selected mode. More... | |
void | EnableIncrementThenHold (int Timesteps) |
Turn on hold after increment. | |
void | EnableOutput (void) |
Enables data logging to all outputs. | |
std::vector< std::string > | EnumerateFDMs (void) |
Returns a vector of strings representing the names of all loaded models (future) | |
void | ForceOutput (int idx=0) |
Forces the specified output object to print its items once. | |
const SGPath & | GetAircraftPath (void) |
Retrieves the aircraft path. | |
childData * | GetChildFDM (int i) const |
Gets a particular child FDM. | |
int | GetDebugLevel (void) const |
Retrieves the current debug level setting. More... | |
double | GetDeltaT (void) const |
Returns the simulation delta T. | |
const SGPath & | GetEnginePath (void) |
Retrieves the engine path. | |
int | GetFDMCount (void) const |
Gets the number of child FDMs. | |
unsigned int | GetFrame (void) const |
Retrieves the current frame count. More... | |
const SGPath & | GetFullAircraftPath (void) |
Retrieves the full aircraft path name. | |
bool | GetHoldDown (void) const |
Gets the value of the property forces/hold-down. More... | |
const std::string & | GetModelName (void) const |
Returns the model name. | |
std::string | GetOutputFileName (int n) const |
Retrieves the current output filename. More... | |
std::vector< std::string > & | GetPropertyCatalog (void) |
FGPropertyManager * | GetPropertyManager (void) |
Returns a pointer to the property manager object. | |
double | GetPropertyValue (const std::string &property) |
Retrieves the value of a property. More... | |
std::string | GetPropulsionTankReport () |
const SGPath & | GetRootDir (void) const |
Retrieves the Root Directory. More... | |
double | GetSimTime (void) const |
Returns the cumulative simulation time in seconds. | |
const SGPath & | GetSystemsPath (void) |
Retrieves the systems path. | |
int | GetTrimMode (void) const |
bool | GetTrimStatus (void) const |
void | Hold (void) |
Pauses execution by preventing time from incrementing. | |
bool | Holding (void) |
Returns true if the simulation is Holding (i.e. simulation time is not moving). | |
double | IncrTime (void) |
Increments the simulation time if not in Holding mode. More... | |
void | Initialize (FGInitialCondition *FGIC) |
Initializes the simulation with initial conditions. More... | |
bool | IntegrationSuspended (void) const |
Returns the simulation suspension state. More... | |
bool | LoadModel (const SGPath &AircraftPath, const SGPath &EnginePath, const SGPath &SystemsPath, const std::string &model, bool addModelToPath=true) |
Loads an aircraft model. More... | |
bool | LoadModel (const std::string &model, bool addModelToPath=true) |
Loads an aircraft model. More... | |
bool | LoadScript (const SGPath &Script, double deltaT=0.0, const SGPath &initfile=SGPath()) |
Loads a script. More... | |
void | PrintPropertyCatalog (void) |
void | PrintSimulationConfiguration (void) const |
std::string | QueryPropertyCatalog (const std::string &check) |
Retrieves property or properties matching the supplied string. More... | |
void | ResetToInitialConditions (int mode) |
Resets the initial conditions object and prepares the simulation to run again. More... | |
void | Resume (void) |
Resumes execution from a "Hold". | |
void | ResumeIntegration (void) |
Resumes the simulation by resetting delta T to the correct value. | |
bool | Run (void) |
This function executes each scheduled model in succession. More... | |
bool | RunIC (void) |
Initializes the sim from the initial condition object and executes each scheduled model without integrating i.e. More... | |
bool | SetAircraftPath (const SGPath &path) |
Sets the path to the aircraft config file directories. More... | |
void | SetChild (bool ch) |
Marks this instance of the Exec object as a "child" object. | |
void | SetDebugLevel (int level) |
Sets the debug level. | |
void | Setdt (double delta_t) |
Sets the integration time step for the simulation executive. More... | |
bool | SetEnginePath (const SGPath &path) |
Sets the path to the engine config file directories. More... | |
void | SetGroundCallback (FGGroundCallback *gc) |
Sets the ground callback pointer. More... | |
void | SetHoldDown (bool hd) |
Sets the property forces/hold-down. More... | |
void | SetLoggingRate (double rate) |
Sets the logging rate in Hz for all output objects (if any). More... | |
bool | SetOutputDirectives (const SGPath &fname) |
Sets the output (logging) mechanism for this run. More... | |
bool | SetOutputFileName (const int n, const std::string &fname) |
Sets (or overrides) the output filename. More... | |
void | SetPropertyValue (const std::string &property, double value) |
Sets a property value. More... | |
void | SetRootDir (const SGPath &rootDir) |
Sets the root directory where JSBSim starts looking for its system directories. More... | |
double | Setsim_time (double cur_time) |
Sets the current sim time. More... | |
bool | SetSystemsPath (const SGPath &path) |
Sets the path to the systems config file directories. More... | |
void | SetTrimMode (int mode) |
void | SetTrimStatus (bool status) |
void | SuspendIntegration (void) |
Suspends the simulation and sets the delta T to zero. | |
void | Unbind (void) |
Unbind all tied JSBSim properties. More... | |
Top-level executive State and Model retrieval mechanism | |
Returns the FGAtmosphere pointer. | |
FGAtmosphere * | GetAtmosphere (void) |
FGAccelerations * | GetAccelerations (void) |
Returns the FGAccelerations pointer. | |
FGWinds * | GetWinds (void) |
Returns the FGWinds pointer. | |
FGFCS * | GetFCS (void) |
Returns the FGFCS pointer. | |
FGPropulsion * | GetPropulsion (void) |
Returns the FGPropulsion pointer. | |
FGMassBalance * | GetMassBalance (void) |
Returns the FGAircraft pointer. | |
FGAerodynamics * | GetAerodynamics (void) |
Returns the FGAerodynamics pointer. | |
FGInertial * | GetInertial (void) |
Returns the FGInertial pointer. | |
FGGroundReactions * | GetGroundReactions (void) |
Returns the FGGroundReactions pointer. | |
FGExternalReactions * | GetExternalReactions (void) |
Returns the FGExternalReactions pointer. | |
FGBuoyantForces * | GetBuoyantForces (void) |
Returns the FGBuoyantForces pointer. | |
FGAircraft * | GetAircraft (void) |
Returns the FGAircraft pointer. | |
FGPropagate * | GetPropagate (void) |
Returns the FGPropagate pointer. | |
FGAuxiliary * | GetAuxiliary (void) |
Returns the FGAuxiliary pointer. | |
FGInput * | GetInput (void) |
Returns the FGInput pointer. | |
FGOutput * | GetOutput (void) |
Returns the FGOutput pointer. | |
FGGroundCallback * | GetGroundCallback (void) |
Get a pointer to the ground callback currently used. More... | |
FGScript * | GetScript (void) |
Retrieves the script object. | |
FGInitialCondition * | GetIC (void) |
Returns a pointer to the FGInitialCondition object. | |
FGTrim * | GetTrim (void) |
Returns a pointer to the FGTrim object. | |
Public Member Functions inherited from FGJSBBase | |
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. More... | |
void | PutMessage (const Message &msg) |
Places a Message structure on the Message queue. More... | |
void | PutMessage (const std::string &text) |
Creates a message with the given text and places it on the queue. More... | |
void | PutMessage (const std::string &text, bool bVal) |
Creates a message with the given text and boolean value and places it on the queue. More... | |
void | PutMessage (const std::string &text, int iVal) |
Creates a message with the given text and integer value and places it on the queue. More... | |
void | PutMessage (const std::string &text, double dVal) |
Creates a message with the given text and double value and places it on the queue. More... | |
int | SomeMessages (void) |
Reads the message on the queue (but does not delete it). More... | |
void | ProcessMessage (void) |
Reads the message on the queue and removes it from the queue. More... | |
Message * | ProcessNextMessage (void) |
Reads the next message on the queue and removes it from the queue. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from FGJSBBase | |
static double | CelsiusToFahrenheit (double celsius) |
Converts from degrees Celsius to degrees Fahrenheit. More... | |
static double | CelsiusToKelvin (double celsius) |
Converts from degrees Celsius to degrees Kelvin. More... | |
static double | CelsiusToRankine (double celsius) |
Converts from degrees Celsius to degrees Rankine. More... | |
static double | Constrain (double min, double value, double max) |
Constrain a value between a minimum and a maximum value. | |
static bool | EqualToRoundoff (double a, double b) |
Finite precision comparison. More... | |
static bool | EqualToRoundoff (float a, float b) |
Finite precision comparison. More... | |
static bool | EqualToRoundoff (float a, double b) |
Finite precision comparison. More... | |
static bool | EqualToRoundoff (double a, float b) |
Finite precision comparison. More... | |
static double | FahrenheitToCelsius (double fahrenheit) |
Converts from degrees Fahrenheit to degrees Celsius. More... | |
static double | FeetToMeters (double measure) |
Converts from feet to meters. More... | |
static double | GaussianRandomNumber (void) |
static double | KelvinToCelsius (double kelvin) |
Converts from degrees Kelvin to degrees Celsius. More... | |
static double | KelvinToFahrenheit (double kelvin) |
Converts from degrees Kelvin to degrees Fahrenheit. More... | |
static double | KelvinToRankine (double kelvin) |
Converts from degrees Kelvin to degrees Rankine. More... | |
static double | MachFromVcalibrated (double vcas, double p, double psl, double rhosl) |
Calculate the Mach number from the calibrated airspeed. More... | |
static double | PitotTotalPressure (double mach, double p) |
Compute the total pressure in front of the Pitot tube. More... | |
static double | RankineToCelsius (double rankine) |
Converts from degrees Rankine to degrees Celsius. More... | |
static double | RankineToKelvin (double rankine) |
Converts from degrees Rankine to degrees Kelvin. More... | |
static double | sign (double num) |
static double | VcalibratedFromMach (double mach, double p, double psl, double rhosl) |
Calculate the calibrated airspeed from the Mach number. More... | |
Static Public Attributes inherited from FGJSBBase | |
static short | debug_lvl = 1 |
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 inherited from FGJSBBase | |
void | Debug (int) |
Static Protected Member Functions inherited from FGJSBBase | |
static std::string | CreateIndexedPropertyName (const std::string &Property, int index) |
Static Protected Attributes inherited from FGJSBBase | |
static const double | degtorad = 0.017453292519943295769236907684886 |
static const double | fpstokts = 1.0/ktstofps |
static const double | fttom = 0.3048 |
static int | gaussian_random_number_phase = 0 |
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 = "1.0 " __DATE__ " " __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 |
Encapsulates the JSBSim simulation executive.
This class is the executive class through which all other simulation classes are instantiated, initialized, and run. When integrated with FlightGear (or other flight simulator) this class is typically instantiated by an interface class on the simulator side.
At the time of simulation initialization, the interface class creates an instance of this executive class. The executive is subsequently directed to load the chosen aircraft specification file:
When an aircraft model is loaded, the config file is parsed and for each of the sections of the config file (propulsion, flight control, etc.) the corresponding Load() method is called (e.g. FGFCS::Load()).
Subsequent to the creation of the executive and loading of the model, initialization is performed. Initialization involves copying control inputs into the appropriate JSBSim data storage locations, configuring it for the set of user supplied initial conditions, and then copying state variables from JSBSim. The state variables are used to drive the instrument displays and to place the vehicle model in world space for visual rendering:
Once initialization is complete, cyclic execution proceeds:
JSBSim can be used in a standalone mode by creating a compact stub program that effectively performs the same progression of steps as outlined above for the integrated version, but with two exceptions. First, the copy_to_JSBSim() and copy_from_JSBSim() functions are not used because the control inputs are handled directly by the scripting facilities and outputs are handled by the output (data logging) class. Second, the name of a script file can be supplied to the stub program. Scripting (see FGScript) provides a way to supply command inputs to the simulation:
The standalone mode has been useful for verifying changes before committing updates to the source code repository. It is also useful for running sets of tests that reveal some aspects of simulated aircraft performance, such as range, time-to-climb, takeoff distance, etc.
This describes to any interested entity the debug level requested by setting the JSBSIM_DEBUG environment variable. The bitmasked value choices are as follows:
Definition at line 189 of file FGFDMExec.h.
void BuildPropertyCatalog | ( | struct PropertyCatalogStructure * | pcs | ) |
Builds a catalog of properties.
This function descends the property tree and creates a list (an STL vector) containing the name and node for all properties.
pcs | The "root" property catalog structure pointer. |
Definition at line 904 of file FGFDMExec.cpp.
void DoTrim | ( | int | mode | ) |
Executes trimming in the selected mode.
mode | Specifies how to trim:
|
Definition at line 1139 of file FGFDMExec.cpp.
|
inline |
Retrieves the current debug level setting.
Definition at line 585 of file FGFDMExec.h.
|
inline |
|
inline |
Get a pointer to the ground callback currently used.
It is recommanded to store the returned pointer in a 'smart pointer' FGGroundCallback_ptr.
Definition at line 381 of file FGFDMExec.h.
|
inline |
Gets the value of the property forces/hold-down.
Definition at line 600 of file FGFDMExec.h.
|
inline |
Retrieves the current output filename.
n | index of file |
Definition at line 460 of file FGFDMExec.h.
|
inline |
Retrieves the value of a property.
property | the name of the property |
Definition at line 402 of file FGFDMExec.h.
|
inline |
Retrieves the Root Directory.
Definition at line 567 of file FGFDMExec.h.
|
inline |
Increments the simulation time if not in Holding mode.
The Frame counter is also incremented.
Definition at line 572 of file FGFDMExec.h.
void Initialize | ( | FGInitialCondition * | FGIC | ) |
Initializes the simulation with initial conditions.
FGIC | The initial conditions that will be passed to the simulation. |
Definition at line 591 of file FGFDMExec.cpp.
|
inline |
Returns the simulation suspension state.
Definition at line 546 of file FGFDMExec.h.
bool LoadModel | ( | const SGPath & | AircraftPath, |
const SGPath & | EnginePath, | ||
const SGPath & | SystemsPath, | ||
const std::string & | model, | ||
bool | addModelToPath = true |
||
) |
Loads an aircraft model.
AircraftPath | path to the aircraft/ directory. For instance: "aircraft". Under aircraft, then, would be directories for various modeled aircraft such as C172/, x15/, etc. |
EnginePath | path to the directory under which engine config files are kept, for instance "engine" |
SystemsPath | path to the directory under which systems config files are kept, for instance "systems" |
model | the name of the aircraft model itself. This file will be looked for in the directory specified in the AircraftPath variable, and in turn under the directory with the same name as the model. For instance: "aircraft/x15/x15.xml" |
addModelToPath | set to true to add the model name to the AircraftPath, defaults to true |
Definition at line 666 of file FGFDMExec.cpp.
bool LoadModel | ( | const std::string & | model, |
bool | addModelToPath = true |
||
) |
Loads an aircraft model.
The paths to the aircraft and engine config file directories must be set prior to calling this. See below.
model | the name of the aircraft model itself. This file will be looked for in the directory specified in the AircraftPath variable, and in turn under the directory with the same name as the model. For instance: "aircraft/x15/x15.xml" |
addModelToPath | set to true to add the model name to the AircraftPath, defaults to true |
Definition at line 679 of file FGFDMExec.cpp.
bool LoadScript | ( | const SGPath & | Script, |
double | deltaT = 0.0 , |
||
const SGPath & | initfile = SGPath() |
||
) |
Loads a script.
Script | The full path name and file name for the script to be loaded. |
deltaT | The simulation integration step size, if given. If no value is supplied then 0.0 is used and the value is expected to be supplied in the script file itself. |
initfile | The initialization file that will override the initialization file specified in the script file. If no file name is given on the command line, the file specified in the script will be used. If an initialization file is not given in either place, an error will result. |
Definition at line 653 of file FGFDMExec.cpp.
string QueryPropertyCatalog | ( | const std::string & | check | ) |
Retrieves property or properties matching the supplied string.
A string is returned that contains a carriage return delimited list of all strings in the property catalog that matches the supplied check string.
check | The string to search for in the property catalog. |
Definition at line 932 of file FGFDMExec.cpp.
void ResetToInitialConditions | ( | int | mode | ) |
Resets the initial conditions object and prepares the simulation to run again.
If mode is set to 1 the output instances will take special actions such as closing the current output file and open a new one with a different name.
mode | Sets the reset mode. |
Definition at line 600 of file FGFDMExec.cpp.
bool Run | ( | void | ) |
This function executes each scheduled model in succession.
Definition at line 310 of file FGFDMExec.cpp.
bool RunIC | ( | void | ) |
Initializes the sim from the initial condition object and executes each scheduled model without integrating i.e.
dt=0.
Definition at line 552 of file FGFDMExec.cpp.
|
inline |
Sets the path to the aircraft config file directories.
path | path to the aircraft directory. For instance: "aircraft". Under aircraft, then, would be directories for various modeled aircraft such as C172/, x15/, etc. |
Definition at line 329 of file FGFDMExec.h.
|
inline |
Sets the integration time step for the simulation executive.
delta_t | the time step in seconds. |
Definition at line 559 of file FGFDMExec.h.
|
inline |
Sets the path to the engine config file directories.
path | path to the directory under which engine config files are kept, for instance "engine" |
Definition at line 320 of file FGFDMExec.h.
|
inline |
Sets the ground callback pointer.
For optimal memory management, a shared pointer is used internally that maintains a reference counter. The calling application must therefore use FGGroundCallback_ptr 'smart pointers' to manage their copy of the ground callback.
gc | A pointer to a ground callback object |
Definition at line 271 of file FGFDMExec.h.
void SetHoldDown | ( | bool | hd | ) |
Sets the property forces/hold-down.
This allows to do hard 'hold-down' such as for rockets on a launch pad with engines ignited.
hd | enables the 'hold-down' function if non-zero |
Definition at line 624 of file FGFDMExec.cpp.
|
inline |
Sets the logging rate in Hz for all output objects (if any).
Definition at line 448 of file FGFDMExec.h.
|
inline |
Sets the output (logging) mechanism for this run.
Calling this function passes the name of an output directives file to the FGOutput object associated with this run. The call to this function should be made prior to loading an aircraft model. This call results in an FGOutput object being built as the first Output object in the FDMExec-managed list of Output objects that may be created for an aircraft model. If this call is made after an aircraft model is loaded, there is no effect. Any Output objects added by the aircraft model itself (in an <output> element) will be added after this one. Care should be taken not to refer to the same file name. An output directives file contains an <output> </output> element, within which should be specified the parameters or parameter groups that should be logged.
fname | the filename of an output directives file. |
Definition at line 441 of file FGFDMExec.h.
|
inline |
Sets (or overrides) the output filename.
n | index of file |
fname | the name of the file to output data to |
Definition at line 454 of file FGFDMExec.h.
|
inline |
Sets a property value.
property | the property to be set |
value | the value to set the property to |
Definition at line 408 of file FGFDMExec.h.
|
inline |
Sets the root directory where JSBSim starts looking for its system directories.
rootDir | the string containing the root directory. |
Definition at line 563 of file FGFDMExec.h.
|
inline |
Sets the current sim time.
cur_time | the current time |
Definition at line 551 of file FGFDMExec.h.
|
inline |
Sets the path to the systems config file directories.
path | path to the directory under which systems config files are kept, for instance "systems" |
Definition at line 337 of file FGFDMExec.h.
|
inline |
Unbind all tied JSBSim properties.
Definition at line 253 of file FGFDMExec.h.