2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2004-06-14 11:40:45 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
Header: FGState.h
|
|
|
|
Author: Jon S. Berndt
|
|
|
|
Date started: 11/17/98
|
2004-06-14 11:40:45 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
|
2004-06-14 11:40:45 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
version.
|
2004-06-14 11:40:45 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
2004-06-14 11:40:45 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place - Suite 330, Boston, MA 02111-1307, USA.
|
2004-06-14 11:40:45 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
Further information about the GNU General Public License can also be found on
|
|
|
|
the world wide web at http://www.gnu.org.
|
2004-06-14 11:40:45 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
FUNCTIONAL DESCRIPTION
|
|
|
|
--------------------------------------------------------------------------------
|
2004-06-14 11:40:45 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
HISTORY
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
11/17/98 JSB Created
|
2004-06-14 11:40:45 +00:00
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-05 21:26:01 +00:00
|
|
|
SENTRY
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-05 21:26:01 +00:00
|
|
|
|
|
|
|
#ifndef FGSTATE_H
|
|
|
|
#define FGSTATE_H
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-05 21:26:01 +00:00
|
|
|
INCLUDES
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-05 21:26:01 +00:00
|
|
|
|
1999-02-26 22:09:10 +00:00
|
|
|
#ifdef FGFS
|
2000-02-15 03:30:01 +00:00
|
|
|
# include <simgear/compiler.h>
|
2001-06-05 20:58:48 +00:00
|
|
|
# ifdef SG_HAVE_STD_INCLUDES
|
1999-02-26 22:09:10 +00:00
|
|
|
# include <fstream>
|
|
|
|
# else
|
|
|
|
# include <fstream.h>
|
|
|
|
# endif
|
|
|
|
#else
|
2004-02-14 10:19:56 +00:00
|
|
|
# if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
|
2001-10-05 20:19:59 +00:00
|
|
|
# include <fstream.h>
|
|
|
|
# else
|
|
|
|
# include <fstream>
|
|
|
|
# endif
|
1999-02-26 22:09:10 +00:00
|
|
|
#endif
|
|
|
|
|
Updates from the Jon and Tony show.
Tony submitted:
JSBsim:
Added trimming routine, it is longitudinal & in-air only at this point
Added support for taking wind & weather data from external source
Added support for flaps.
Added independently settable pitch trim
Added alphamin and max to config file, stall modeling and warning to
follow
c172.cfg:
Flaps!
Adjusted Cmo, model should be speed stable now
FG:
Hooked up Christian's weather code, should be using it soon.
Hooked up the trimming routine. Note that the X-15 will not trim.
This is not a model or trimming routine deficiency, just the
nature of the X-15
The trimming routine sets the pitch trim and and throttle at startup.
The throttle is set using Norman's code for the autothrottle so the
autothrottle is on by default. --notrim will turn it off.
Added --vc, --mach, and --notrim switches
(vc is airspeed in knots)
uBody, vBody, and wBody are still supported, last one entered
on the command line counts, i.e. you can set vc or mach or u,v,
and w but any combination will be ignored.
2000-05-16 21:35:11 +00:00
|
|
|
#include <string>
|
2000-04-24 23:49:06 +00:00
|
|
|
#include <map>
|
2001-10-05 20:19:59 +00:00
|
|
|
#include "FGJSBBase.h"
|
1999-08-17 21:18:11 +00:00
|
|
|
#include "FGInitialCondition.h"
|
2001-10-05 20:19:59 +00:00
|
|
|
#include "FGMatrix33.h"
|
|
|
|
#include "FGColumnVector3.h"
|
2004-06-14 11:40:45 +00:00
|
|
|
#include "FGQuaternion.h"
|
2002-09-22 15:31:09 +00:00
|
|
|
#include "FGFDMExec.h"
|
|
|
|
#include "FGAtmosphere.h"
|
|
|
|
#include "FGFCS.h"
|
2004-06-14 11:40:45 +00:00
|
|
|
#include "FGPropagate.h"
|
|
|
|
#include "FGAuxiliary.h"
|
2002-09-22 15:31:09 +00:00
|
|
|
#include "FGAerodynamics.h"
|
|
|
|
#include "FGOutput.h"
|
|
|
|
#include "FGAircraft.h"
|
|
|
|
#include "FGGroundReactions.h"
|
|
|
|
#include "FGPropulsion.h"
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2001-04-17 21:19:54 +00:00
|
|
|
DEFINITIONS
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2001-03-30 01:04:50 +00:00
|
|
|
#define ID_STATE "$Id$"
|
2000-10-14 02:10:10 +00:00
|
|
|
|
2001-04-17 21:19:54 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
FORWARD DECLARATIONS
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
2003-06-03 08:46:15 +00:00
|
|
|
namespace JSBSim {
|
|
|
|
|
2001-04-17 21:19:54 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
CLASS DOCUMENTATION
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
/** Encapsulates the calculation of aircraft state.
|
|
|
|
@author Jon S. Berndt
|
|
|
|
@version $Id$
|
|
|
|
*/
|
|
|
|
|
2000-11-03 23:02:47 +00:00
|
|
|
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
1999-02-05 21:26:01 +00:00
|
|
|
CLASS DECLARATION
|
2000-11-03 23:02:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
class FGState : public FGJSBBase
|
|
|
|
{
|
1999-02-05 21:26:01 +00:00
|
|
|
public:
|
2001-10-05 20:19:59 +00:00
|
|
|
/** Constructor
|
|
|
|
@param Executive a pointer to the parent executive object */
|
Updates from the Jon and Tony show.
Tony submitted:
JSBsim:
Added trimming routine, it is longitudinal & in-air only at this point
Added support for taking wind & weather data from external source
Added support for flaps.
Added independently settable pitch trim
Added alphamin and max to config file, stall modeling and warning to
follow
c172.cfg:
Flaps!
Adjusted Cmo, model should be speed stable now
FG:
Hooked up Christian's weather code, should be using it soon.
Hooked up the trimming routine. Note that the X-15 will not trim.
This is not a model or trimming routine deficiency, just the
nature of the X-15
The trimming routine sets the pitch trim and and throttle at startup.
The throttle is set using Norman's code for the autothrottle so the
autothrottle is on by default. --notrim will turn it off.
Added --vc, --mach, and --notrim switches
(vc is airspeed in knots)
uBody, vBody, and wBody are still supported, last one entered
on the command line counts, i.e. you can set vc or mach or u,v,
and w but any combination will be ignored.
2000-05-16 21:35:11 +00:00
|
|
|
FGState(FGFDMExec*);
|
2001-10-05 20:19:59 +00:00
|
|
|
/// Destructor
|
2001-03-30 01:04:50 +00:00
|
|
|
~FGState();
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
/** Initializes the simulation state based on parameters from an Initial Conditions object.
|
|
|
|
@param FGIC pointer to an initial conditions object.
|
|
|
|
@see FGInitialConditions.
|
|
|
|
*/
|
1999-08-17 21:18:11 +00:00
|
|
|
void Initialize(FGInitialCondition *FGIC);
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
/// Returns the simulation time in seconds.
|
2002-03-20 12:45:02 +00:00
|
|
|
inline double Getsim_time(void) const { return sim_time; }
|
2001-10-05 20:19:59 +00:00
|
|
|
/// Returns the simulation delta T.
|
2001-11-20 22:34:24 +00:00
|
|
|
inline double Getdt(void) { return dt; }
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
/// Suspends the simulation and sets the delta T to zero.
|
2000-10-02 23:07:30 +00:00
|
|
|
inline void Suspend(void) {saved_dt = dt; dt = 0.0;}
|
2001-10-05 20:19:59 +00:00
|
|
|
/// Resumes the simulation by resetting delta T to the correct value.
|
2000-10-02 23:07:30 +00:00
|
|
|
inline void Resume(void) {dt = saved_dt;}
|
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
/** Sets the current sim time.
|
|
|
|
@param cur_time the current time
|
|
|
|
@return the current time.
|
|
|
|
*/
|
2001-11-20 22:34:24 +00:00
|
|
|
inline double Setsim_time(double cur_time) {
|
2001-10-05 20:19:59 +00:00
|
|
|
sim_time = cur_time;
|
Updates from the Jon and Tony show.
Tony submitted:
JSBsim:
Added trimming routine, it is longitudinal & in-air only at this point
Added support for taking wind & weather data from external source
Added support for flaps.
Added independently settable pitch trim
Added alphamin and max to config file, stall modeling and warning to
follow
c172.cfg:
Flaps!
Adjusted Cmo, model should be speed stable now
FG:
Hooked up Christian's weather code, should be using it soon.
Hooked up the trimming routine. Note that the X-15 will not trim.
This is not a model or trimming routine deficiency, just the
nature of the X-15
The trimming routine sets the pitch trim and and throttle at startup.
The throttle is set using Norman's code for the autothrottle so the
autothrottle is on by default. --notrim will turn it off.
Added --vc, --mach, and --notrim switches
(vc is airspeed in knots)
uBody, vBody, and wBody are still supported, last one entered
on the command line counts, i.e. you can set vc or mach or u,v,
and w but any combination will be ignored.
2000-05-16 21:35:11 +00:00
|
|
|
return sim_time;
|
|
|
|
}
|
2004-06-14 11:40:45 +00:00
|
|
|
|
2001-10-05 20:19:59 +00:00
|
|
|
/** Sets the integration time step for the simulation executive.
|
|
|
|
@param delta_t the time step in seconds.
|
|
|
|
*/
|
2001-11-20 22:34:24 +00:00
|
|
|
inline void Setdt(double delta_t) { dt = delta_t; }
|
2001-10-05 20:19:59 +00:00
|
|
|
|
|
|
|
/** Increments the simulation time.
|
|
|
|
@return the new simulation time.
|
|
|
|
*/
|
2001-11-20 22:34:24 +00:00
|
|
|
inline double IncrTime(void) {
|
Updates from the Jon and Tony show.
Tony submitted:
JSBsim:
Added trimming routine, it is longitudinal & in-air only at this point
Added support for taking wind & weather data from external source
Added support for flaps.
Added independently settable pitch trim
Added alphamin and max to config file, stall modeling and warning to
follow
c172.cfg:
Flaps!
Adjusted Cmo, model should be speed stable now
FG:
Hooked up Christian's weather code, should be using it soon.
Hooked up the trimming routine. Note that the X-15 will not trim.
This is not a model or trimming routine deficiency, just the
nature of the X-15
The trimming routine sets the pitch trim and and throttle at startup.
The throttle is set using Norman's code for the autothrottle so the
autothrottle is on by default. --notrim will turn it off.
Added --vc, --mach, and --notrim switches
(vc is airspeed in knots)
uBody, vBody, and wBody are still supported, last one entered
on the command line counts, i.e. you can set vc or mach or u,v,
and w but any combination will be ignored.
2000-05-16 21:35:11 +00:00
|
|
|
sim_time+=dt;
|
|
|
|
return sim_time;
|
|
|
|
}
|
2001-10-05 20:19:59 +00:00
|
|
|
|
|
|
|
/** Calculates and returns the stability-to-body axis transformation matrix.
|
|
|
|
@return a reference to the stability-to-body transformation matrix.
|
|
|
|
*/
|
2001-11-20 22:34:24 +00:00
|
|
|
FGMatrix33& GetTs2b(void);
|
2004-06-14 11:40:45 +00:00
|
|
|
|
2001-11-30 17:49:37 +00:00
|
|
|
/** Calculates and returns the body-to-stability axis transformation matrix.
|
|
|
|
@return a reference to the stability-to-body transformation matrix.
|
|
|
|
*/
|
|
|
|
FGMatrix33& GetTb2s(void);
|
2001-10-05 20:19:59 +00:00
|
|
|
|
2004-06-14 11:40:45 +00:00
|
|
|
/** Prints a summary of simulator state (speed, altitude,
|
2001-10-05 20:19:59 +00:00
|
|
|
configuration, etc.)
|
|
|
|
*/
|
|
|
|
void ReportState(void);
|
2004-06-14 11:40:45 +00:00
|
|
|
|
2002-03-20 12:45:02 +00:00
|
|
|
void bind();
|
|
|
|
void unbind();
|
2001-10-05 20:19:59 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
private:
|
2001-11-20 22:34:24 +00:00
|
|
|
double sim_time, dt;
|
|
|
|
double saved_dt;
|
1999-02-05 21:26:01 +00:00
|
|
|
|
1999-02-11 21:05:34 +00:00
|
|
|
FGFDMExec* FDMExec;
|
2001-10-05 20:19:59 +00:00
|
|
|
FGMatrix33 mTs2b;
|
2001-11-30 17:49:37 +00:00
|
|
|
FGMatrix33 mTb2s;
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2001-04-17 21:19:54 +00:00
|
|
|
FGAircraft* Aircraft;
|
2004-06-14 11:40:45 +00:00
|
|
|
FGPropagate* Propagate;
|
2001-04-17 21:19:54 +00:00
|
|
|
FGOutput* Output;
|
|
|
|
FGAtmosphere* Atmosphere;
|
|
|
|
FGFCS* FCS;
|
2001-06-05 20:58:48 +00:00
|
|
|
FGAerodynamics* Aerodynamics;
|
2001-10-29 19:00:24 +00:00
|
|
|
FGGroundReactions* GroundReactions;
|
2001-10-30 02:51:13 +00:00
|
|
|
FGPropulsion* Propulsion;
|
2004-06-14 11:40:45 +00:00
|
|
|
FGAuxiliary* Auxiliary;
|
2002-03-20 12:45:02 +00:00
|
|
|
FGPropertyManager* PropertyManager;
|
2001-04-17 21:19:54 +00:00
|
|
|
|
2001-12-13 04:48:34 +00:00
|
|
|
void Debug(int from);
|
1999-02-05 21:26:01 +00:00
|
|
|
};
|
2003-01-24 12:55:28 +00:00
|
|
|
}
|
2000-11-03 23:02:47 +00:00
|
|
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2001-04-17 21:19:54 +00:00
|
|
|
|
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
#endif
|
2001-03-30 01:04:50 +00:00
|
|
|
|