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"
57 #define ID_TRIMAXIS "$Header"
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"
66 /*******************************************************************************
68 *******************************************************************************/
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 };
76 FGTrimAxis(FGFDMExec* fdmex, FGInitialCondition *ic, Accel acc,
77 Control ctrl, float tolerance);
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; }
87 inline Accel GetAccelType(void) { return accel; }
88 inline Control GetControlType(void) { return control; }
90 inline string GetAccelName(void) { return AccelNames[accel]; }
91 inline string GetControlName(void) { return ControlNames[control]; }
93 inline float GetControlMin(void) { return control_min; }
94 inline float GetControlMax(void) { return control_max; }
96 inline void SetControlToMin(void) { control_value=control_min; }
97 inline void SetControlToMax(void) { control_value=control_max; }
99 inline void SetTolerance(float ff) { tolerance=ff;}
100 inline float GetTolerance(void) { return tolerance; }
102 inline float GetSolverEps(void) { return solver_eps; }
103 inline void SetSolverEps(float ff) { solver_eps=ff; }
105 inline int GetIterationLimit(void) { return max_iterations; }
106 inline void SetIterationLimit(int ii) { max_iterations=ii; }
108 inline int GetStability(void) { return its_to_stable_value; }
109 inline int GetRunCount(void) { return total_stability_iterations; }
110 float GetAvgStability( void );
112 void SetThetaOnGround(float ff);
113 void SetPhiOnGround(float ff);
115 void AxisReport(void);
117 bool InTolerance(void) { getAccel(); return (fabs(accel_value) <= tolerance); }
121 FGInitialCondition *fgic;
138 float control_convert;
142 int its_to_stable_value;
143 int total_stability_iterations;
144 int total_iterations;
147 void setThrottlesPct(void);
150 void getControl(void);
151 void setControl(void);