]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGTrimAxis.h
FG_HAVE_STD_INCLUDES -> SG_HAVE_STD_INCLUDES
[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 #define ID_TRIMAXIS "$Header"
58
59 const string AccelNames[6]=   { "udot","vdot","wdot","qdot","pdot","rdot" };
60 const string ControlNames[13]= { "Throttle","Sideslip","Angle of Attack",
61                                  "Elevator","Ailerons","Rudder",
62                                  "Altitude AGL", "Pitch Angle",
63                                  "Roll Angle", "Flight Path Angle", 
64                                  "Pitch Trim", "Roll Trim", "Yaw Trim"
65                                };
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 CLASS DECLARATION
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69
70 enum Accel { tUdot,tVdot,tWdot,tQdot,tPdot,tRdot };
71 enum Control { tThrottle, tBeta, tAlpha, tElevator, tAileron, tRudder, tAltAGL,
72                tTheta, tPhi, tGamma, tPitchTrim, tRollTrim, tYawTrim };
73
74 class FGTrimAxis {
75 public:
76   FGTrimAxis(FGFDMExec* fdmex, FGInitialCondition *ic, Accel acc,
77              Control ctrl, float tolerance);
78   ~FGTrimAxis();
79
80   void Run(void);
81  
82   float GetAccel(void) { getAccel(); return accel_value; }
83   //Accels are not settable
84   inline void SetControl(float value ) { control_value=value; }
85   inline float GetControl(void) { return control_value; }
86
87   inline Accel GetAccelType(void) { return accel; }
88   inline Control GetControlType(void) { return control; }
89
90   inline string GetAccelName(void) { return AccelNames[accel]; }
91   inline string GetControlName(void) { return ControlNames[control]; }
92
93   inline float GetControlMin(void) { return control_min; }
94   inline float GetControlMax(void) { return control_max; }
95
96   inline void SetControlToMin(void) { control_value=control_min; }
97   inline void SetControlToMax(void) { control_value=control_max; }
98   
99   inline void SetControlLimits(float min, float max) { 
100       control_min=min;
101       control_max=max;
102   }    
103
104   inline void  SetTolerance(float ff) { tolerance=ff;}
105   inline float GetTolerance(void) { return tolerance; }
106
107   inline float GetSolverEps(void) { return solver_eps; }
108   inline void SetSolverEps(float ff) { solver_eps=ff; }
109
110   inline int  GetIterationLimit(void) { return max_iterations; }
111   inline void SetIterationLimit(int ii) { max_iterations=ii; }
112
113   inline int GetStability(void) { return its_to_stable_value; }
114   inline int GetRunCount(void) { return total_stability_iterations; }
115   float GetAvgStability( void );
116   
117   void SetThetaOnGround(float ff);
118   void SetPhiOnGround(float ff);
119   
120   bool initTheta(void);
121   
122   void AxisReport(void);
123   
124   bool InTolerance(void) { getAccel(); return (fabs(accel_value) <= tolerance); }
125
126 private:
127   FGFDMExec *fdmex;
128   FGInitialCondition *fgic;
129
130
131   Accel   accel;
132   Control control;
133
134   float accel_value;
135   float control_value;
136
137   float control_min;
138   float control_max;
139
140   float tolerance;
141
142   float solver_eps;
143
144   float accel_convert;
145   float control_convert;
146
147   int max_iterations;
148
149   int its_to_stable_value;
150   int total_stability_iterations;
151   int total_iterations;
152
153
154   void setThrottlesPct(void);
155
156   void getAccel(void);
157   void getControl(void);
158   void setControl(void);
159   
160   
161
162 };
163
164 #endif