1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) 1998 by Jon S. Berndt, jon@jsbsim.org -------------
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
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
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.
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.
27 --------------------------------------------------------------------------------
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
36 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 #include "FGFCSComponent.h"
41 #include "math/FGTable.h"
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47 #define ID_GAIN "$Id: FGGain.h,v 1.14 2009/10/24 22:59:30 jberndt Exp $"
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62 /** Encapsulates a gain component for the flight control system.
63 The gain component merely multiplies the input by a gain. The <b>pure gain</b> form
64 of the component specification is:
67 <pure_gain name="name">
68 <input> {[-]property} </input>
69 <gain> {property name | value} </gain>
71 <min> {property name | value} </min>
72 <max> {property name | value} </max>
74 [<output> {property} </output>]
81 <pure_gain name="Roll AP Wing Leveler">
82 <input>fcs/attitude/sensor/phi-rad</input>
91 Note: the input property name may be immediately preceded by a minus sign to
94 The <b>scheduled gain</b> component multiplies the input by a variable gain that is
95 dependent on another property (such as qbar, altitude, etc.). The lookup
96 mapping is in the form of a table. This kind of component might be used, for
97 example, in a case where aerosurface deflection must only be commanded to
98 acceptable settings - i.e at higher qbar the commanded elevator setting might
99 be attenuated. The form of the scheduled gain component specification is:
102 <scheduled_gain name="name">
103 <input> {[-]property} </input>
110 <min> {[-]property name | value} </min>
111 <max> {[-]property name | value} </max>
113 [<gain> {property name | value} </gain>]
114 [<output> {property} </output>]
121 <scheduled_gain name="Scheduled Steer Pos Deg">
122 <input>fcs/steer-cmd-norm</input>
124 <independentVar>velocities/vg-fps</independentVar>
132 <output>fcs/steer-pos-rad</output>
136 An overall GAIN may be supplied that is multiplicative with the scheduled gain.
138 Note: the input property name may be immediately preceded by a minus sign to
141 In the example above, we see the utility of the overall gain value in
142 effecting a degrees-to-radians conversion.
144 The <b>aerosurface scale</b> component is a modified version of the simple gain
145 component. The purpose for this component is to take control inputs from the
146 domain minimum and maximum, as specified (or from -1 to +1 by default) and
147 scale them to map to a specified range. This can be done, for instance, to match
148 the component outputs to the expected inputs to a flight control system.
150 The zero_centered element dictates whether the domain-to-range mapping is linear
151 or centered about zero. For example, if zero_centered is false, and if the domain
152 or range is not symmetric about zero, and an input value is zero, the output
153 will not be zero. Let's say that the domain is min=-2 and max=+4, with a range
154 of -1 to +1. If the input is 0.0, then the "normalized" input is calculated to
155 be 33% of the way from the minimum to the maximum. That input would be mapped
156 to an output of -0.33, which is 33% of the way from the range minimum to maximum.
157 If zero_centered is set to true (or 1) then an input of 0.0 will be mapped to an
158 output of 0.0, although if either the domain or range are unsymmetric about
159 0.0, then the scales for the positive and negative portions of the input domain
160 (above and below 0.0) will be different. The zero_centered element is true by
161 default. Note that this feature may be important for some control surface mappings,
162 where the maximum upper and lower deflections may be different, but where a zero
163 setting is desired to be the "undeflected" value, and where full travel of the
164 stick is desired to cause a full deflection of the control surface.
166 The form of the aerosurface scaling component specification is:
169 <aerosurface_scale name="name">
170 <input> {[-]property name} </input>
172 <min> {value} </min> <!-- If omitted, default is -1.0 ->
173 <max> {value} </max> <!-- If omitted, default is 1.0 ->
176 <min> {value} </min> <!-- If omitted, default is 0 ->
177 <max> {value} </max> <!-- If omitted, default is 0 ->
179 <zero_centered< value </zero_centered>
181 <min> {[-]property name | value} </min>
182 <max> {[-]property name | value} </max>
184 [<gain> {property name | value} </gain>]
185 [<output> {property} </output>]
189 Note: the input property name may be immediately preceded by a minus sign to
192 For instance, the normal and expected ability of a
193 pilot to push or pull on a control stick is about 50 pounds. The input to the
194 pitch channel block diagram of a flight control system is often in units of pounds.
195 Yet, the joystick control input usually defines a span from -1 to +1. The aerosurface_scale
196 form of the gain component maps the inputs to the desired output range. The example
197 below shoes a simple aerosurface_scale component that maps the joystick
198 input to a range of +/- 50, which represents pilot stick force in pounds for the F-16.
201 <aerosurface_scale name="Pilot input">
202 <input>fcs/elevator-cmd-norm</input>
204 <min> -50 </min> <!-- If omitted, default is 0 ->
205 <max> 50 </max> <!-- If omitted, default is 0 ->
210 @author Jon S. Berndt
211 @version $Revision: 1.14 $
214 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
218 class FGGain : public FGFCSComponent
221 FGGain(FGFCS* fcs, Element* element);
228 FGPropertyManager* GainPropertyNode;
229 double GainPropertySign;
231 double InMin, InMax, OutMin, OutMax;
235 void Debug(int from);