FlightGear next
FGTrimAxis.h
Go to the documentation of this file.
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 "FGFDMExec.h"
44#include "FGJSBBase.h"
45#include "FGInitialCondition.h"
46
47/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48DEFINITIONS
49%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50
51#define DEFAULT_TOLERANCE 0.001
52
53/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54FORWARD DECLARATIONS
55%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56
57namespace JSBSim {
58
59const std::string StateNames[] = { "all","udot","vdot","wdot","qdot","pdot",
60 "rdot","hmgt","nlf"
61 };
62const std::string ControlNames[] = { "Throttle","Sideslip","Angle of Attack",
63 "Elevator","Ailerons","Rudder",
64 "Altitude AGL", "Pitch Angle",
65 "Roll Angle", "Flight Path Angle",
66 "Pitch Trim", "Roll Trim", "Yaw Trim",
67 "Heading"
68 };
69
70class FGInitialCondition;
71
72/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73CLASS DOCUMENTATION
74%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75
78
79/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80CLASS DECLARATION
81%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
82
86
87class FGTrimAxis : public FGJSBBase
88{
89public:
95 FGTrimAxis(FGFDMExec* fdmex,
97 State state,
98 Control control );
100 ~FGTrimAxis();
101
104 void Run(void);
105
106 double GetState(void) { getState(); return state_value; }
107 //Accels are not settable
108 inline void SetControl(double value ) { control_value=value; }
109 inline double GetControl(void) { return control_value; }
110
111 inline State GetStateType(void) { return state; }
112 inline Control GetControlType(void) { return control; }
113
114 inline std::string GetStateName(void) { return StateNames[state]; }
115 inline std::string GetControlName(void) { return ControlNames[control]; }
116
117 inline double GetControlMin(void) { return control_min; }
118 inline double GetControlMax(void) { return control_max; }
119
120 inline void SetControlToMin(void) { control_value=control_min; }
121 inline void SetControlToMax(void) { control_value=control_max; }
122
123 inline void SetControlLimits(double min, double max) {
124 control_min=min;
125 control_max=max;
126 }
127
128 inline void SetTolerance(double ff) { tolerance=ff;}
129 inline double GetTolerance(void) { return tolerance; }
130
131 inline double GetSolverEps(void) { return solver_eps; }
132 inline void SetSolverEps(double ff) { solver_eps=ff; }
133
134 inline int GetIterationLimit(void) { return max_iterations; }
135 inline void SetIterationLimit(int ii) { max_iterations=ii; }
136
137 inline int GetStability(void) { return its_to_stable_value; }
138 inline int GetRunCount(void) { return total_stability_iterations; }
139 double GetAvgStability( void );
140
141 inline void SetStateTarget(double target) { state_target=target; }
142 inline double GetStateTarget(void) { return state_target; }
143
144 void AxisReport(void);
145
146 bool InTolerance(void) { getState(); return (fabs(state_value) <= tolerance); }
147
148private:
149 FGFDMExec *fdmex;
150 FGInitialCondition *fgic;
151
152 State state;
153 Control control;
154
155 double state_target;
156
157 double state_value;
158 double control_value;
159
160 double control_min;
161 double control_max;
162
163 double tolerance;
164
165 double solver_eps;
166
167 double state_convert;
168 double control_convert;
169
170 int max_iterations;
171
172 int its_to_stable_value;
173 int total_stability_iterations;
174 int total_iterations;
175
176 void setThrottlesPct(void);
177
178 void getState(void);
179 void getControl(void);
180 void setControl(void);
181
182 double computeHmgt(void);
183
184 void Debug(int from);
185};
186}
187#endif
#define min(X, Y)
FGJSBBase()
Constructor for FGJSBBase.
Definition FGJSBBase.h:81
int GetRunCount(void)
Definition FGTrimAxis.h:138
void SetIterationLimit(int ii)
Definition FGTrimAxis.h:135
int GetIterationLimit(void)
Definition FGTrimAxis.h:134
int GetStability(void)
Definition FGTrimAxis.h:137
double GetStateTarget(void)
Definition FGTrimAxis.h:142
double GetSolverEps(void)
Definition FGTrimAxis.h:131
void SetStateTarget(double target)
Definition FGTrimAxis.h:141
double GetState(void)
Definition FGTrimAxis.h:106
double GetControlMin(void)
Definition FGTrimAxis.h:117
State GetStateType(void)
Definition FGTrimAxis.h:111
std::string GetStateName(void)
Definition FGTrimAxis.h:114
void SetControlToMin(void)
Definition FGTrimAxis.h:120
double GetAvgStability(void)
std::string GetControlName(void)
Definition FGTrimAxis.h:115
void SetControl(double value)
Definition FGTrimAxis.h:108
void SetControlToMax(void)
Definition FGTrimAxis.h:121
FGTrimAxis(FGFDMExec *fdmex, FGInitialCondition *IC, State state, Control control)
Constructor for Trim Axis class.
double GetControlMax(void)
Definition FGTrimAxis.h:118
void SetTolerance(double ff)
Definition FGTrimAxis.h:128
void SetSolverEps(double ff)
Definition FGTrimAxis.h:132
double GetControl(void)
Definition FGTrimAxis.h:109
void SetControlLimits(double min, double max)
Definition FGTrimAxis.h:123
Control GetControlType(void)
Definition FGTrimAxis.h:112
void AxisReport(void)
bool InTolerance(void)
Definition FGTrimAxis.h:146
~FGTrimAxis()
Destructor.
double GetTolerance(void)
Definition FGTrimAxis.h:129
void Run(void)
This function iterates through a call to the FGFDMExec::RunIC() function until the desired trimming c...
@ tAltAGL
Definition FGTrimAxis.h:84
@ tYawTrim
Definition FGTrimAxis.h:85
@ tHeading
Definition FGTrimAxis.h:85
@ tElevator
Definition FGTrimAxis.h:84
@ tPitchTrim
Definition FGTrimAxis.h:85
@ tRollTrim
Definition FGTrimAxis.h:85
@ tRudder
Definition FGTrimAxis.h:84
@ tThrottle
Definition FGTrimAxis.h:84
@ tAileron
Definition FGTrimAxis.h:84
const std::string StateNames[]
Definition FGTrimAxis.h:59
const std::string ControlNames[]
Definition FGTrimAxis.h:62
State
Models an aircraft axis for purposes of trimming.
Definition FGTrimAxis.h:83