1999-02-05 21:26:01 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
|
|
|
|
Header: FGState.h
|
|
|
|
Author: Jon S. Berndt
|
|
|
|
Date started: 11/17/98
|
|
|
|
|
|
|
|
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
Further information about the GNU General Public License can also be found on
|
|
|
|
the world wide web at http://www.gnu.org.
|
|
|
|
|
|
|
|
FUNCTIONAL DESCRIPTION
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Based on Flightgear code, which is based on LaRCSim. This class wraps all
|
|
|
|
global state variables (such as velocity, position, orientation, etc.).
|
|
|
|
|
|
|
|
HISTORY
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
11/17/98 JSB Created
|
|
|
|
|
1999-02-11 21:05:34 +00:00
|
|
|
********************************************************************************
|
1999-02-05 21:26:01 +00:00
|
|
|
SENTRY
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef FGSTATE_H
|
|
|
|
#define FGSTATE_H
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
INCLUDES
|
|
|
|
*******************************************************************************/
|
|
|
|
|
1999-02-26 22:09:10 +00:00
|
|
|
#ifdef FGFS
|
2000-02-15 03:30:01 +00:00
|
|
|
# include <simgear/compiler.h>
|
1999-02-26 22:09:10 +00:00
|
|
|
# include STL_STRING
|
|
|
|
# ifdef FG_HAVE_STD_INCLUDES
|
|
|
|
# include <fstream>
|
|
|
|
# else
|
|
|
|
# include <fstream.h>
|
|
|
|
# endif
|
|
|
|
FG_USING_STD(string);
|
|
|
|
#else
|
|
|
|
# include <string>
|
|
|
|
# include <fstream>
|
|
|
|
#endif
|
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
#include <map>
|
1999-02-11 21:05:34 +00:00
|
|
|
#include "FGDefs.h"
|
1999-08-17 21:18:11 +00:00
|
|
|
#include "FGInitialCondition.h"
|
2000-04-24 23:49:06 +00:00
|
|
|
#include "FGMatrix.h"
|
1999-02-05 21:26:01 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
DEFINES
|
|
|
|
*******************************************************************************/
|
|
|
|
|
1999-05-08 03:19:08 +00:00
|
|
|
using namespace std;
|
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
CLASS DECLARATION
|
|
|
|
*******************************************************************************/
|
|
|
|
|
1999-02-11 21:05:34 +00:00
|
|
|
class FGFDMExec;
|
1999-08-17 21:18:11 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
class FGState
|
|
|
|
{
|
|
|
|
public:
|
1999-02-11 21:05:34 +00:00
|
|
|
FGState(FGFDMExec*);
|
1999-02-05 21:26:01 +00:00
|
|
|
~FGState(void);
|
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
bool Reset(string, string, string);
|
1999-07-31 04:55:23 +00:00
|
|
|
void Initialize(float, float, float, float, float, float, float, float, float);
|
1999-08-17 21:18:11 +00:00
|
|
|
void Initialize(FGInitialCondition *FGIC);
|
1999-02-26 22:09:10 +00:00
|
|
|
bool StoreData(string);
|
1999-02-05 21:26:01 +00:00
|
|
|
|
|
|
|
inline float GetVt(void) {return Vt;}
|
|
|
|
|
|
|
|
inline float Getlatitude(void) {return latitude;}
|
|
|
|
inline float Getlongitude(void) {return longitude;}
|
|
|
|
inline float GetGeodeticLat(void) {return GeodeticLat;}
|
|
|
|
|
|
|
|
inline float Getadot(void) {return adot;}
|
|
|
|
inline float Getbdot(void) {return bdot;}
|
|
|
|
|
1999-12-20 20:24:49 +00:00
|
|
|
inline float GetLocalAltitudeOverRunway(void) {return LocalAltitudeOverRunway;}
|
1999-02-05 21:26:01 +00:00
|
|
|
inline float Geth(void) {return h;}
|
|
|
|
inline float Geta(void) {return a;}
|
|
|
|
inline float GetMach(void) {return Mach;}
|
1999-02-11 21:05:34 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
inline float Getsim_time(void) {return sim_time;}
|
|
|
|
inline float Getdt(void) {return dt;}
|
|
|
|
|
|
|
|
inline float Getqbar(void) {return qbar;}
|
2000-04-24 23:49:06 +00:00
|
|
|
float GetParameter(int val_idx);
|
|
|
|
float GetParameter(string val_string);
|
|
|
|
int GetParameterIndex(string val_string);
|
1999-02-05 21:26:01 +00:00
|
|
|
|
|
|
|
inline void SetVt(float tt) {Vt = tt;}
|
|
|
|
|
|
|
|
inline void Setlatitude(float tt) {latitude = tt;}
|
|
|
|
inline void Setlongitude(float tt) {longitude = tt;}
|
|
|
|
inline void SetGeodeticLat(float tt) {GeodeticLat = tt;}
|
|
|
|
|
|
|
|
inline void Setadot(float tt) {adot = tt;}
|
|
|
|
inline void Setbdot(float tt) {bdot = tt;}
|
|
|
|
|
|
|
|
inline void Setqbar(float tt) {qbar = tt;}
|
|
|
|
|
1999-12-20 20:24:49 +00:00
|
|
|
inline void SetLocalAltitudeOverRunway(float tt) {LocalAltitudeOverRunway = tt;}
|
1999-02-05 21:26:01 +00:00
|
|
|
inline void Seth(float tt) {h = tt;}
|
|
|
|
inline void Seta(float tt) {a = tt;}
|
|
|
|
inline void SetMach(float tt) {Mach = tt;}
|
|
|
|
|
|
|
|
inline float Setsim_time(float tt) {sim_time = tt; return sim_time;}
|
1999-02-11 21:05:34 +00:00
|
|
|
inline void Setdt(float tt) {dt = tt;}
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
void SetParameter(int, float);
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
inline float IncrTime(void) {sim_time+=dt;return sim_time;}
|
|
|
|
void InitMatrices(float phi, float tht, float psi);
|
|
|
|
void CalcMatrices(void);
|
|
|
|
void IntegrateQuat(FGColumnVector vPQR, int rate);
|
|
|
|
FGColumnVector CalcEuler(void);
|
|
|
|
FGMatrix GetTs2b(float alpha, float beta);
|
|
|
|
FGMatrix GetTl2b(void) {return mTl2b;}
|
|
|
|
FGMatrix GetTb2l(void) {return mTb2l;}
|
1999-12-20 20:24:49 +00:00
|
|
|
|
1999-02-05 21:26:01 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
float Vt; // Total velocity
|
|
|
|
float latitude, longitude; // position
|
|
|
|
float GeodeticLat; // Geodetic Latitude
|
|
|
|
float adot, bdot; // alpha dot and beta dot
|
|
|
|
float h, a; // altitude above sea level, speed of sound
|
1999-02-11 21:05:34 +00:00
|
|
|
float qbar; // dynamic pressure
|
1999-02-05 21:26:01 +00:00
|
|
|
float sim_time, dt;
|
|
|
|
float Mach; // Mach number
|
|
|
|
|
1999-02-11 21:05:34 +00:00
|
|
|
FGFDMExec* FDMExec;
|
1999-12-20 20:24:49 +00:00
|
|
|
float LocalAltitudeOverRunway;
|
2000-04-24 23:49:06 +00:00
|
|
|
FGMatrix mTb2l;
|
|
|
|
FGMatrix mTl2b;
|
|
|
|
FGMatrix mTs2b;
|
|
|
|
FGColumnVector vQtrn;
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
typedef map<string, long> CoeffMap;
|
|
|
|
CoeffMap coeffdef;
|
1999-02-05 21:26:01 +00:00
|
|
|
|
2000-04-24 23:49:06 +00:00
|
|
|
protected:
|
|
|
|
enum {ePhi=1, eTht, ePsi};
|
|
|
|
enum {eP=1, eQ, eR};
|
1999-02-05 21:26:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
#endif
|