Loading [MathJax]/extensions/tex2jax.js
JSBSim Flight Dynamics Model 1.2.2 (22 Mar 2025)
An Open Source Flight Dynamics and Control Software Library in C++
All Classes Functions Variables Enumerations Enumerator Friends Pages
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 Lesser 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 Lesser General Public License for more
17 details.
18
19 You should have received a copy of the GNU Lesser 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 Lesser General Public License can also be found on
24 the world wide web at http://www.gnu.org.
25
26 HISTORY
27--------------------------------------------------------------------------------
287/3/00 TP Created
29
30%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31SENTRY
32%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34#ifndef FGTRIMAXIS_H
35#define FGTRIMAXIS_H
36
37/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38INCLUDES
39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41#include <string>
42
43#include "FGJSBBase.h"
44
45/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46DEFINITIONS
47%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48
49#define DEFAULT_TOLERANCE 0.001
50
51/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52FORWARD DECLARATIONS
53%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54
55namespace JSBSim {
56
57const std::string StateNames[] = { "all","udot","vdot","wdot","qdot","pdot",
58 "rdot","hmgt","nlf"
59 };
60const std::string ControlNames[] = { "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 "Heading"
66 };
67
68class FGInitialCondition;
69class FGFDMExec;
70
71/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72CLASS DOCUMENTATION
73%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
74
78/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79CLASS DECLARATION
80%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
81
82enum State { tAll,tUdot,tVdot,tWdot,tQdot,tPdot,tRdot,tHmgt,tNlf };
83enum Control { tThrottle, tBeta, tAlpha, tElevator, tAileron, tRudder, tAltAGL,
84 tTheta, tPhi, tGamma, tPitchTrim, tRollTrim, tYawTrim, tHeading };
85
86class FGTrimAxis : public FGJSBBase
87{
88public:
94 FGTrimAxis(FGFDMExec* fdmex,
96 State state,
97 Control control );
100
103 void Run(void);
104
105 double GetState(void) { getState(); return state_value; }
106 //Accels are not settable
107 inline void SetControl(double value ) { control_value=value; }
108 inline double GetControl(void) { return control_value; }
109
110 inline State GetStateType(void) { return state; }
111 inline Control GetControlType(void) { return control; }
112
113 inline std::string GetStateName(void) { return StateNames[state]; }
114 inline std::string GetControlName(void) { return ControlNames[control]; }
115
116 inline double GetControlMin(void) { return control_min; }
117 inline double GetControlMax(void) { return control_max; }
118
119 inline void SetControlToMin(void) { control_value=control_min; }
120 inline void SetControlToMax(void) { control_value=control_max; }
121
122 inline void SetControlLimits(double min, double max) {
123 control_min=min;
124 control_max=max;
125 }
126
127 inline void SetTolerance(double ff) { tolerance=ff;}
128 inline double GetTolerance(void) { return tolerance; }
129
130 inline double GetSolverEps(void) { return solver_eps; }
131 inline void SetSolverEps(double ff) { solver_eps=ff; }
132
133 inline int GetIterationLimit(void) { return max_iterations; }
134 inline void SetIterationLimit(int ii) { max_iterations=ii; }
135
136 inline int GetStability(void) { return its_to_stable_value; }
137 inline int GetRunCount(void) { return total_stability_iterations; }
138 double GetAvgStability( void );
139
140 inline void SetStateTarget(double target) { state_target=target; }
141 inline double GetStateTarget(void) { return state_target; }
142
143 void AxisReport(void);
144
145 bool InTolerance(void) { getState(); return (fabs(state_value) <= tolerance); }
146
147private:
148 FGFDMExec *fdmex;
149 FGInitialCondition *fgic;
150
151 State state;
152 Control control;
153
154 double state_target;
155
156 double state_value;
157 double control_value;
158
159 double control_min;
160 double control_max;
161
162 double tolerance;
163
164 double solver_eps;
165
166 double state_convert;
167 double control_convert;
168
169 int max_iterations;
170
171 int its_to_stable_value;
172 int total_stability_iterations;
173 int total_iterations;
174
175 void setThrottlesPct(void);
176
177 void getState(void);
178 void getControl(void);
179 void setControl(void);
180
181 double computeHmgt(void);
182
183 void Debug(int from);
184};
185}
186#endif
Encapsulates the JSBSim simulation executive.
Definition FGFDMExec.h:184
Initializes the simulation run.
JSBSim Base class.
Definition FGJSBBase.h:117
void Run(void)
This function iterates through a call to the FGFDMExec::RunIC() function until the desired trimming c...
~FGTrimAxis()
Destructor.