]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGTrimAxis.h
Oct 2, 2000 JSBSim sync.
[flightgear.git] / src / FDM / JSBSim / FGTrimAxis.h
1 /*******************************************************************************
2  
3  Header:       FGTrimAxis.h
4  Author:       Tony Peden
5  Date started: 7/3/00
6  
7  ------------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) -------------
8  
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13  
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  details.
18  
19  You should have received a copy of the GNU General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22  
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25  
26  
27  HISTORY
28 --------------------------------------------------------------------------------
29 7/3/00  TP   Created
30  
31  
32  
33 ********************************************************************************
34 SENTRY
35 *******************************************************************************/
36
37 #ifndef FGTRIMAXIS_H
38 #define FGTRIMAXIS_H
39
40 /*******************************************************************************
41 INCLUDES
42 *******************************************************************************/
43
44 #include <string>
45
46 #include "FGFDMExec.h"
47 #include "FGRotation.h"
48 #include "FGAtmosphere.h"
49 #include "FGState.h"
50 #include "FGFCS.h"
51 #include "FGAircraft.h"
52 #include "FGTranslation.h"
53 #include "FGPosition.h"
54 #include "FGAuxiliary.h"
55 #include "FGOutput.h"
56
57
58 const string AccelNames[6]=   { "udot","vdot","wdot","qdot","pdot","rdot" };
59 const string ControlNames[13]= { "Throttle","Sideslip","Angle of Attack",
60                                  "Elevator","Ailerons","Rudder",
61                                  "Altitude AGL", "Pitch Angle",
62                                  "Roll Angle", "Flight Path Angle", 
63                                  "Pitch Trim", "Roll Trim", "Yaw Trim"
64                                };
65 /*******************************************************************************
66 CLASS DECLARATION
67 *******************************************************************************/
68
69 enum Accel { tUdot,tVdot,tWdot,tQdot,tPdot,tRdot };
70 enum Control { tThrottle, tBeta, tAlpha, tElevator, tAileron, tRudder, tAltAGL,
71                tTheta, tPhi, tGamma, tPitchTrim, tRollTrim, tYawTrim };
72
73 class FGTrimAxis {
74 public:
75   FGTrimAxis(FGFDMExec* fdmex, FGInitialCondition *ic, Accel acc,
76              Control ctrl, float tolerance);
77   ~FGTrimAxis();
78
79   void Run(void);
80
81   float GetAccel(void) { getAccel(); return accel_value; }
82   //Accels are not settable
83   inline void SetControl(float value ) { control_value=value; }
84   inline float GetControl(void) { return control_value; }
85
86   inline Accel GetAccelType(void) { return accel; }
87   inline Control GetControlType(void) { return control; }
88
89   inline string GetAccelName(void) { return AccelNames[accel]; }
90   inline string GetControlName(void) { return ControlNames[control]; }
91
92   inline float GetControlMin(void) { return control_min; }
93   inline float GetControlMax(void) { return control_max; }
94
95   inline void SetControlToMin(void) { control_value=control_min; }
96   inline void SetControlToMax(void) { control_value=control_max; }
97
98   inline void  SetTolerance(float ff) { tolerance=ff;}
99   inline float GetTolerance(void) { return tolerance; }
100
101   inline float GetSolverEps(void) { return solver_eps; }
102   inline void SetSolverEps(float ff) { solver_eps=ff; }
103
104   inline int  GetIterationLimit(void) { return max_iterations; }
105   inline void SetIterationLimit(int ii) { max_iterations=ii; }
106
107   inline int GetStability(void) { return its_to_stable_value; }
108   inline int GetRunCount(void) { return total_stability_iterations; }
109   float GetAvgStability( void );
110   
111   void SetThetaOnGround(float ff);
112   void SetPhiOnGround(float ff);
113
114   void AxisReport(void);
115   
116   bool InTolerance(void) { getAccel(); return (fabs(accel_value) <= tolerance); }
117
118 private:
119   FGFDMExec *fdmex;
120   FGInitialCondition *fgic;
121
122
123   Accel   accel;
124   Control control;
125
126   float accel_value;
127   float control_value;
128
129   float control_min;
130   float control_max;
131
132   float tolerance;
133
134   float solver_eps;
135
136   float accel_convert;
137   float control_convert;
138
139   int max_iterations;
140
141   int its_to_stable_value;
142   int total_stability_iterations;
143   int total_iterations;
144
145
146   void setThrottlesPct(void);
147
148   void getAccel(void);
149   void getControl(void);
150   void setControl(void);
151
152 };
153
154 #endif