]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/flight_control/FGGain.h
sync. with JSBSim v. 2.0
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGGain.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGGain.h
4  Author:
5  Date started:
6
7  ------------- Copyright (C)  -------------
8
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
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 General Public License for more
17  details.
18
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.
22
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 SENTRY
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
32
33 #ifndef FGGAIN_H
34 #define FGGAIN_H
35
36 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 INCLUDES
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40 #ifdef FGFS
41 #  include <simgear/compiler.h>
42 #  include STL_STRING
43    SG_USING_STD(string);
44 #else
45 #  include <string>
46 #endif
47
48 #include "FGFCSComponent.h"
49 #include <input_output/FGXMLElement.h>
50 #include <math/FGTable.h>
51
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 DEFINITIONS
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
56 #define ID_GAIN "$Id$"
57
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 FORWARD DECLARATIONS
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61
62 namespace JSBSim {
63
64 class FGFCS;
65
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 CLASS DOCUMENTATION
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69
70 /** Encapsulates a gain component for the flight control system.
71     The gain component merely multiplies the input by a gain.  The form of the
72     gain component specification is:
73     <pre>
74     \<component name="name" type="PURE_GAIN">
75       \<input> property \</input>
76       \<gain> value \</gain>
77       [\<output> property \</output>]
78     \</component>
79     </pre>
80     Note: as is the case with the Summer component, the input property name may be
81     immediately preceded by a minus sign to invert that signal.
82
83     The scheduled gain component multiplies the input by a variable gain that is
84     dependent on another property (such as qbar, altitude, etc.).  The lookup
85     mapping is in the form of a table.  This kind of component might be used, for
86     example, in a case where aerosurface deflection must only be commanded to
87     acceptable settings - i.e at higher qbar the commanded elevator setting might
88     be attenuated.  The form of the scheduled gain component specification is:
89     <pre>
90     \<COMPONENT NAME="name" TYPE="SCHEDULED_GAIN">
91       INPUT \<property>
92       [GAIN  \<value>]
93       SCHEDULED_BY \<property>
94       ROWS \<number_of_rows>
95       \<lookup_value  gain_value>
96       ?
97       [CLIPTO \<min> \<max> 1]
98       [OUTPUT \<property>]
99     \</COMPONENT>
100     </pre>
101     An overall GAIN may be supplied that is multiplicative with the scheduled gain.
102
103     Note: as is the case with the Summer component, the input property name may
104     be immediately preceded by a minus sign to invert that signal.
105
106     Here is an example of a scheduled gain component specification:
107     <pre>
108     \<COMPONENT NAME="Pitch Scheduled Gain 1" TYPE="SCHEDULED_GAIN">
109       INPUT        fcs/pitch-gain-1
110       GAIN         0.017
111       SCHEDULED_BY fcs/elevator-pos-rad
112       ROWS         22
113       -0.68  -26.548
114       -0.595 -20.513
115       -0.51  -15.328
116       -0.425 -10.993
117       -0.34   -7.508
118       -0.255  -4.873
119       -0.17   -3.088
120       -0.085  -2.153
121        0      -2.068
122        0.085  -2.833
123        0.102  -3.088
124        0.119  -3.377
125        0.136  -3.7
126        0.153  -4.057
127        0.17   -4.448
128        0.187  -4.873
129        0.272  -7.508
130        0.357 -10.993
131        0.442 -15.328
132        0.527 -20.513
133        0.612 -26.548
134        0.697 -33.433
135     \</COMPONENT>
136     </pre>
137     In the example above, we see the utility of the overall GAIN value in
138     effecting a degrees-to-radians conversion.
139
140     The aerosurface scale component is a modified version of the simple gain
141     component.  The normal purpose
142     for this component is to take control inputs that range from -1 to +1 or
143     from 0 to +1 and scale them to match the expected inputs to a flight control
144     system.  For instance, the normal and expected ability of a pilot to push or
145     pull on a control stick is about 50 pounds.  The input to the pitch channelb
146     lock diagram of a flight control system is in units of pounds.  Yet, the
147     joystick control input is usually in a range from -1 to +1.  The form of the
148     aerosurface scaling component specification is:
149 <pre>
150     \<COMPONENT NAME="name" TYPE="AEROSURFACE_SCALE">
151       INPUT \<property>
152       MIN \<value>
153       MAX \<value>
154       [GAIN  \<value>]
155       [OUTPUT \<property>]
156     \</COMPONENT>
157 </pre>
158     Note: as is the case with the Summer component, the input property name may be
159     immediately preceded by a minus sign to invert that signal.
160
161     @author Jon S. Berndt
162     @version $Id$
163 */
164
165 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
166 CLASS DECLARATION
167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
168
169 class FGGain  : public FGFCSComponent
170 {
171 public:
172   FGGain(FGFCS* fcs, Element* element);
173   ~FGGain();
174
175   bool Run (void);
176
177 private:
178   FGTable* Table;
179   FGPropertyManager* GainPropertyNode;
180   double Gain;
181   double InMin, InMax, OutMin, OutMax;
182   int Rows;
183   bool ZeroCentered;
184
185   void Debug(int from);
186 };
187 }
188 #endif