]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/filtersjb/FGGain.h
Rob Deters: UIUC updates from March 1, 2004.
[flightgear.git] / src / FDM / JSBSim / filtersjb / 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 "../FGConfigFile.h"
50 #include "../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>
76       GAIN  \<value>
77       [OUTPUT \<property>]
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       [OUTPUT \<property>]
98     \</COMPONENT>
99     </pre>
100     An overall GAIN may be supplied that is multiplicative with the scheduled gain.
101
102     Note: as is the case with the Summer component, the input property name may
103     be immediately preceded by a minus sign to invert that signal.
104
105     Here is an example of a scheduled gain component specification:
106     <pre>
107     \<COMPONENT NAME="Pitch Scheduled Gain 1" TYPE="SCHEDULED_GAIN">
108       INPUT        fcs/pitch-gain-1
109       GAIN         0.017
110       SCHEDULED_BY fcs/elevator-pos-rad
111       ROWS         22
112       -0.68  -26.548
113       -0.595 -20.513
114       -0.51  -15.328
115       -0.425 -10.993
116       -0.34   -7.508
117       -0.255  -4.873
118       -0.17   -3.088
119       -0.085  -2.153
120        0      -2.068
121        0.085  -2.833
122        0.102  -3.088
123        0.119  -3.377
124        0.136  -3.7
125        0.153  -4.057
126        0.17   -4.448
127        0.187  -4.873
128        0.272  -7.508
129        0.357 -10.993
130        0.442 -15.328
131        0.527 -20.513
132        0.612 -26.548
133        0.697 -33.433
134     \</COMPONENT>
135     </pre>
136     In the example above, we see the utility of the overall GAIN value in
137     effecting a degrees-to-radians conversion.
138
139     The aerosurface scale component is a modified version of the simple gain
140     component.  The normal purpose
141     for this component is to take control inputs that range from -1 to +1 or
142     from 0 to +1 and scale them to match the expected inputs to a flight control
143     system.  For instance, the normal and expected ability of a pilot to push or
144     pull on a control stick is about 50 pounds.  The input to the pitch channelb
145     lock diagram of a flight control system is in units of pounds.  Yet, the
146     joystick control input is usually in a range from -1 to +1.  The form of the
147     aerosurface scaling component specification is:
148 <pre>
149     \<COMPONENT NAME="name" TYPE="AEROSURFACE_SCALE">
150       INPUT \<property>
151       MIN \<value>
152       MAX \<value>
153       [GAIN  \<value>]
154       [OUTPUT \<property>]
155     \</COMPONENT>
156 </pre>
157     Note: as is the case with the Summer component, the input property name may be
158     immediately preceded by a minus sign to invert that signal.
159
160     @author Jon S. Berndt
161     @version $Id$
162 */
163
164 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165 CLASS DECLARATION
166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
167
168 class FGGain  : public FGFCSComponent
169 {
170 public:
171   FGGain(FGFCS* fcs, FGConfigFile* AC_cfg);
172   ~FGGain();
173   
174   double GetOutputPct() const { return OutputPct; }
175   
176   bool Run (void);
177
178 private:
179   FGConfigFile* AC_cfg;
180   FGTable* Table;
181   FGState* State;
182   double Gain;
183   double Min, Max;
184   double OutputPct;
185   bool invert;
186   int Rows;
187   FGPropertyManager* ScheduledBy;
188
189   void Debug(int from);
190 };
191 }
192 #endif