1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 3 Header: FGGain.h 4 Author: Jon Berndt 5 Date started: 1998 ? 6 7 ------------- Copyright (C) 1998 by Jon S. Berndt, jon@jsbsim.org ------------- 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 11 Software Foundation; either version 2 of the License, or (at your option) any 12 later 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 20 with this program; if not, write to the Free Software Foundation, Inc., 59 21 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 23 Further information about the GNU Lesser General Public License can also be 24 found on 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 #include "FGFCSComponent.h" 41 42 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 43 FORWARD DECLARATIONS 44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ 45 46 namespace JSBSim { 47 48 class FGFCS; 49 class Element; 50 class FGTable; 51 52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 53 CLASS DOCUMENTATION 54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ 55 56 /** Encapsulates a gain component for the flight control system. 57 The gain component merely multiplies the input by a gain. The 58 <b>pure gain</b> form of the component specification is: 59 60 @code 61 <pure_gain name="name"> 62 <input> {[-]property} </input> 63 <gain> {property name | value} </gain> 64 [<clipto> 65 <min> {property name | value} </min> 66 <max> {property name | value} </max> 67 </clipto>] 68 [<output> {property} </output>] 69 </pure_gain> 70 @endcode 71 72 Example: 73 74 @code 75 <pure_gain name="Roll AP Wing Leveler"> 76 <input>fcs/attitude/sensor/phi-rad</input> 77 <gain>2.0</gain> 78 <clipto> 79 <min>-0.255</min> 80 <max>0.255</max> 81 </clipto> 82 </pure_gain> 83 @endcode 84 85 Note: the input property name may be immediately preceded by a minus sign to 86 invert that signal. 87 88 The <b>scheduled gain</b> component multiplies the input by a variable gain 89 that is dependent on another property (such as qbar, altitude, etc.). The 90 lookup mapping is in the form of a table. This kind of component might be 91 used, for example, in a case where aerosurface deflection must only be 92 commanded to acceptable settings - i.e at higher qbar the commanded elevator 93 setting might be attenuated. The form of the scheduled gain component 94 specification is: 95 96 @code 97 <scheduled_gain name="name"> 98 <input> {[-]property} </input> 99 <table> 100 <tableData> 101 ... 102 </tableData> 103 </table> 104 [<clipto> 105 <min> {[-]property name | value} </min> 106 <max> {[-]property name | value} </max> 107 </clipto>] 108 [<gain> {property name | value} </gain>] 109 [<output> {property} </output>] 110 </scheduled_gain> 111 @endcode 112 113 Example: 114 115 @code 116 <scheduled_gain name="Scheduled Steer Pos Deg"> 117 <input>fcs/steer-cmd-norm</input> 118 <table> 119 <independentVar>velocities/vg-fps</independentVar> 120 <tableData> 121 10.0 80.0 122 50.0 15.0 123 150.0 2.0 124 </tableData> 125 </table> 126 <gain>0.017</gain> 127 <output>fcs/steer-pos-rad</output> 128 </scheduled_gain> 129 @endcode 130 131 An overall GAIN may be supplied that is multiplicative with the scheduled 132 gain. 133 134 Note: the input property name may be immediately preceded by a minus sign to 135 invert that signal. 136 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 <b>aerosurface scale</b> component is a modified version of the simple 141 gain component. The purpose for this component is to take control inputs 142 from the domain minimum and maximum, as specified (or from -1 to +1 by 143 default) and scale them to map to a specified range. This can be done, for 144 instance, to match the component outputs to the expected inputs to a flight 145 control system. 146 147 The zero_centered element dictates whether the domain-to-range mapping is 148 linear or centered about zero. For example, if zero_centered is false, and 149 if the domain or range is not symmetric about zero, and an input value is 150 zero, the output will not be zero. Let's say that the domain is min=-2 and 151 max=+4, with a range of -1 to +1. If the input is 0.0, then the "normalized" 152 input is calculated to be 33% of the way from the minimum to the 153 maximum. That input would be mapped to an output of -0.33, which is 33% of 154 the way from the range minimum to maximum. If zero_centered is set to true 155 (or 1) then an input of 0.0 will be mapped to an output of 0.0, although if 156 either the domain or range are unsymmetric about 0.0, then the scales for 157 the positive and negative portions of the input domain (above and below 0.0) 158 will be different. The zero_centered element is true by default. Note that 159 this feature may be important for some control surface mappings, where the 160 maximum upper and lower deflections may be different, but where a zero 161 setting is desired to be the "undeflected" value, and where full travel of 162 the stick is desired to cause a full deflection of the control surface. 163 164 The form of the aerosurface scaling component specification is: 165 166 @code 167 <aerosurface_scale name="name"> 168 <input> {[-]property name} </input> 169 <domain> 170 <min> {value} </min> <!-- If omitted, default is -1.0 -> 171 <max> {value} </max> <!-- If omitted, default is 1.0 -> 172 </domain> 173 <range> 174 <min> {value} </min> <!-- If omitted, default is 0 -> 175 <max> {value} </max> <!-- If omitted, default is 0 -> 176 </range> 177 <zero_centered< value </zero_centered> 178 [<clipto> 179 <min> {[-]property name | value} </min> 180 <max> {[-]property name | value} </max> 181 </clipto>] 182 [<gain> {property name | value} </gain>] 183 [<output> {property} </output>] 184 </aerosurface_scale> 185 @endcode 186 187 Note: the input property name may be immediately preceded by a minus sign to 188 invert that signal. 189 190 For instance, the normal and expected ability of a pilot to push or pull on 191 a control stick is about 50 pounds. The input to the pitch channel block 192 diagram of a flight control system is often in units of pounds. Yet, the 193 joystick control input usually defines a span from -1 to +1. The 194 aerosurface_scale form of the gain component maps the inputs to the desired 195 output range. The example below shoes a simple aerosurface_scale component 196 that maps the joystick input to a range of +/- 50, which represents pilot 197 stick force in pounds for the F-16. 198 199 @code 200 <aerosurface_scale name="Pilot input"> 201 <input>fcs/elevator-cmd-norm</input> 202 <range> 203 <min> -50 </min> <!-- If omitted, default is 0 -> 204 <max> 50 </max> <!-- If omitted, default is 0 -> 205 </range> 206 </aerosurface_scale> 207 @endcode 208 209 @author Jon S. Berndt 210 @version $Revision$ 211 */ 212 213 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 214 CLASS DECLARATION 215 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ 216 217 class FGGain : public FGFCSComponent 218 { 219 public: 220 FGGain(FGFCS* fcs, Element* element); 221 ~FGGain(); 222 223 bool Run (void) override; 224 225 private: 226 FGTable* Table; 227 FGParameter_ptr Gain; 228 double InMin, InMax, OutMin, OutMax; 229 bool ZeroCentered; 230 231 void Debug(int from) override; 232 }; 233 } 234 #endif 235