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
FGTrim.h
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGTrim.h
4 Author: Tony Peden
5 Date started: 7/1/99
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
27 HISTORY
28--------------------------------------------------------------------------------
299/8/99 TP Created
30
31
32FUNCTIONAL DESCRIPTION
33--------------------------------------------------------------------------------
34
35This class takes the given set of IC's and finds the aircraft state required to
36maintain a specified flight condition. This flight condition can be
37steady-level with non-zero sideslip, a steady turn, a pull-up or pushover.
38On-ground conditions can be trimmed as well, but this is currently limited to
39adjusting altitude and pitch angle only. It is implemented using an iterative,
40one-axis-at-a-time scheme.
41
42%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43SENTRY
44%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45
46#ifndef FGTRIM_H
47#define FGTRIM_H
48
49/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50INCLUDES
51%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53#include "FGJSBBase.h"
54#include "FGTrimAxis.h"
55#include "FGInitialCondition.h"
56
57#include <vector>
58
59/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60FORWARD DECLARATIONS
61%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63namespace JSBSim {
64
65class FGFDMExec;
66
67typedef enum { tLongitudinal=0, tFull, tGround, tPullup,
68 tCustom, tTurn, tNone } TrimMode;
69
70/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71CLASS DOCUMENTATION
72%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
73
121/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122CLASS DECLARATION
123%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
124
125class JSBSIM_API FGTrim : public FGJSBBase
126{
127 std::vector<FGTrimAxis> TrimAxes;
128 unsigned int Nsub;
129 TrimMode mode;
130 int DebugLevel, Debug;
131 double Tolerance, A_Tolerance;
132 std::vector<double> sub_iterations, successful;
133 std::vector<bool> solution;
134 unsigned int max_sub_iterations;
135 unsigned int max_iterations;
136 unsigned int total_its;
137 bool gamma_fallback;
138 int solutionDomain;
139 double xlo,xhi,alo,ahi;
140 double targetNlf;
141 int debug_axis;
142
143 double psidot;
144
145 FGFDMExec* fdmex;
147
148 bool solve(FGTrimAxis& axis);
149
157 bool findInterval(FGTrimAxis& axis);
158
159 bool checkLimits(FGTrimAxis& axis);
160
161 void setupPullup(void);
162 void setupTurn(void);
163
164 void updateRates(void);
165 void setDebug(FGTrimAxis& axis);
166
167 struct ContactPoints {
168 FGColumnVector3 location;
169 FGColumnVector3 normal;
170 };
171
172 struct RotationParameters {
173 double angleMin;
174 std::vector<ContactPoints>::iterator contactRef;
175 };
176
177 void trimOnGround(void);
178 RotationParameters calcRotation(std::vector<ContactPoints>& contacts,
179 const FGColumnVector3& rotationAxis,
180 const FGColumnVector3& contact0);
181
182public:
187 FGTrim(FGFDMExec *FDMExec, TrimMode tm=tGround );
188
189 ~FGTrim(void);
190
193 bool DoTrim(void);
194
200 void Report(void);
201
204 void TrimStats();
205
210 void SetMode(TrimMode tm);
211
216 void ClearStates(void);
217
225 bool AddState( State state, Control control );
226
231 bool RemoveState( State state );
232
237 bool EditState( State state, Control new_control );
238
244 inline void SetGammaFallback(bool bb) { gamma_fallback=bb; }
245
249 inline bool GetGammaFallback(void) { return gamma_fallback; }
250
256 inline void SetMaxCycles(int ii) { max_iterations = ii; }
257
264 inline void SetMaxCyclesPerAxis(int ii) { max_sub_iterations = ii; }
265
270 inline void SetTolerance(double tt) {
271 Tolerance = tt;
272 A_Tolerance = tt / 10;
273 }
274
279 inline void SetDebug(int level) { DebugLevel = level; }
280 inline void ClearDebug(void) { DebugLevel = 0; }
281
286 inline void DebugState(State state) { debug_axis=state; }
287
288 inline void SetTargetNlf(double nlf) { targetNlf=nlf; }
289 inline double GetTargetNlf(void) { return targetNlf; }
290
291};
292}
293
294#endif
This class implements a 3 element column vector.
Encapsulates the JSBSim simulation executive.
Definition FGFDMExec.h:184
Initializes the simulation run.
JSBSim Base class.
Definition FGJSBBase.h:117
The trimming routine for JSBSim.
Definition FGTrim.h:126
void SetGammaFallback(bool bb)
automatically switch to trimming longitudinal acceleration with flight path angle (gamma) once it bec...
Definition FGTrim.h:244
void SetMaxCycles(int ii)
Set the iteration limit.
Definition FGTrim.h:256
void SetMaxCyclesPerAxis(int ii)
Set the per-axis iteration limit.
Definition FGTrim.h:264
void SetDebug(int level)
Debug level 1 shows results of each top-level iteration Debug level 2 shows level 1 & results of each...
Definition FGTrim.h:279
bool GetGammaFallback(void)
query the fallback state
Definition FGTrim.h:249
void DebugState(State state)
Output debug data for one of the axes The State enum is defined in FGTrimAxis.h.
Definition FGTrim.h:286
void SetTolerance(double tt)
Set the tolerance for declaring a state trimmed.
Definition FGTrim.h:270