1 /*******************************************************************************
7 ------------- Copyright (C) 1999 Anthony K. Peden (apeden@earthlink.net) -------------
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
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
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.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
28 --------------------------------------------------------------------------------
33 ********************************************************************************
35 *******************************************************************************/
40 /*******************************************************************************
42 *******************************************************************************/
46 #include "FGFDMExec.h"
47 #include "FGRotation.h"
48 #include "FGAtmosphere.h"
51 #include "FGAircraft.h"
52 #include "FGTranslation.h"
53 #include "FGPosition.h"
54 #include "FGAuxiliary.h"
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"
65 /*******************************************************************************
67 *******************************************************************************/
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 };
75 FGTrimAxis(FGFDMExec* fdmex, FGInitialCondition *ic, Accel acc,
76 Control ctrl, float tolerance);
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; }
86 inline Accel GetAccelType(void) { return accel; }
87 inline Control GetControlType(void) { return control; }
89 inline string GetAccelName(void) { return AccelNames[accel]; }
90 inline string GetControlName(void) { return ControlNames[control]; }
92 inline float GetControlMin(void) { return control_min; }
93 inline float GetControlMax(void) { return control_max; }
95 inline void SetControlToMin(void) { control_value=control_min; }
96 inline void SetControlToMax(void) { control_value=control_max; }
98 inline void SetTolerance(float ff) { tolerance=ff;}
99 inline float GetTolerance(void) { return tolerance; }
101 inline float GetSolverEps(void) { return solver_eps; }
102 inline void SetSolverEps(float ff) { solver_eps=ff; }
104 inline int GetIterationLimit(void) { return max_iterations; }
105 inline void SetIterationLimit(int ii) { max_iterations=ii; }
107 inline int GetStability(void) { return its_to_stable_value; }
108 inline int GetRunCount(void) { return total_stability_iterations; }
109 float GetAvgStability( void );
111 void SetThetaOnGround(float ff);
112 void SetPhiOnGround(float ff);
114 void AxisReport(void);
116 bool InTolerance(void) { getAccel(); return (fabs(accel_value) <= tolerance); }
120 FGInitialCondition *fgic;
137 float control_convert;
141 int its_to_stable_value;
142 int total_stability_iterations;
143 int total_iterations;
146 void setThrottlesPct(void);
149 void getControl(void);
150 void setControl(void);