1
0
Fork 0
flightgear/src/FDM/JSBSim/FGState.h

145 lines
4.1 KiB
C
Raw Normal View History

2000-11-03 23:02:47 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1999-02-05 21:26:01 +00:00
Header: FGState.h
Author: Jon S. Berndt
Date started: 11/17/98
1999-02-05 21:26:01 +00:00
------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
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.
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.
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.
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.
1999-02-05 21:26:01 +00:00
FUNCTIONAL DESCRIPTION
--------------------------------------------------------------------------------
1999-02-05 21:26:01 +00:00
Based on Flightgear code, which is based on LaRCSim. This class wraps all
global state variables (such as velocity, position, orientation, etc.).
1999-02-05 21:26:01 +00:00
HISTORY
--------------------------------------------------------------------------------
11/17/98 JSB Created
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
#ifdef FGFS
2000-02-15 03:30:01 +00:00
# include <simgear/compiler.h>
# ifdef SG_HAVE_STD_INCLUDES
# include <fstream>
# else
# include <fstream.h>
# endif
#else
# include <fstream>
#endif
#include <string>
2000-04-24 23:49:06 +00:00
#include <map>
#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
2000-11-03 23:02:47 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1999-02-05 21:26:01 +00:00
DEFINES
2000-11-03 23:02:47 +00:00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
1999-02-05 21:26:01 +00:00
#define ID_STATE "$Header$"
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
class FGFDMExec;
1999-08-17 21:18:11 +00:00
class FGState {
1999-02-05 21:26:01 +00:00
public:
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);
bool StoreData(string);
1999-02-05 21:26:01 +00:00
inline float Geta(void) { return a; }
inline float Getsim_time(void) { return sim_time; }
inline float Getdt(void) { return dt; }
1999-02-05 21:26:01 +00:00
2000-10-02 23:07:30 +00:00
inline void Suspend(void) {saved_dt = dt; dt = 0.0;}
inline void Resume(void) {dt = saved_dt;}
float GetParameter(eParam val_idx);
2000-04-24 23:49:06 +00:00
float GetParameter(string val_string);
2000-10-02 23:07:30 +00:00
eParam GetParameterIndex(string val_string);
1999-02-05 21:26:01 +00:00
inline void Seta(float tt) { a = tt; }
1999-02-05 21:26:01 +00:00
inline float Setsim_time(float tt) {
sim_time = tt;
return sim_time;
}
inline void Setdt(float tt) { dt = tt; }
1999-02-05 21:26:01 +00:00
2000-10-02 23:07:30 +00:00
void SetParameter(eParam, float);
1999-02-05 21:26:01 +00:00
inline float IncrTime(void) {
sim_time+=dt;
return sim_time;
}
2000-04-24 23:49:06 +00:00
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; }
2000-10-02 23:07:30 +00:00
typedef map<eParam, string> ParamMap;
ParamMap paramdef;
1999-12-20 20:24:49 +00:00
1999-02-05 21:26:01 +00:00
private:
2000-04-28 19:59:46 +00:00
float a; // speed of sound
1999-02-05 21:26:01 +00:00
float sim_time, dt;
2000-10-02 23:07:30 +00:00
float saved_dt;
1999-02-05 21:26:01 +00:00
FGFDMExec* FDMExec;
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-10-02 23:07:30 +00:00
typedef map<string, eParam> CoeffMap;
2000-04-24 23:49:06 +00:00
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
};
2000-11-03 23:02:47 +00:00
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1999-02-05 21:26:01 +00:00
#endif