Debian Codegraph @

src/FDM/JSBSim/models/flight_control/FGPID.h

raw symbols SCIP
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGPID.h
4 Author: Jon Berndt
5 Date started: 6/17/2006
6
7 ------------- Copyright (C) 2006 by Jon S. Berndt, [email protected] -------------
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 Initial Code 6/17/2006 JSB
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGPID_H
35 #define FGPID_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #include "FGFCSComponent.h"
42
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 FORWARD DECLARATIONS
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46
47 namespace JSBSim {
48
49 class FGFCS;
50 class Element;
51 class FGParameter;
52
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 CLASS DOCUMENTATION
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56
57 /** Encapsulates a PID control component for the flight control system.
58
59 <h3>Configuration Format:</h3>
60
61 @code
62 <pid name="{string}" [type="standard"]>
63 <input> {[-]property} </input>
64 <kp> {number|[-]property} </kp>
65 <ki type="rect|trap|ab2|ab3"> {number|[-]property} </ki>
66 <kd> {number|[-]property} </kd>
67 <trigger> {property} </trigger>
68 <pvdot> {property} </pvdot>
69 </pid>
70 @endcode
71
72 For the integration constant element, one can also supply the type attribute for
73 what kind of integrator to be used, one of:
74
75 - rect, for a rectangular integrator
76 - trap, for a trapezoidal integrator
77 - ab2, for a second order Adams Bashforth integrator
78 - ab3, for a third order Adams Bashforth integrator
79
80 For example,
81
82 @code
83 <pid name="fcs/heading-control">
84 <input> fcs/heading-error </input>
85 <kp> 3 </kp>
86 <ki type="ab3"> 1 </ki>
87 <kd> 1 </kd>
88 </pid>
89 @endcode
90
91 <h3>Configuration Parameters:</h3>
92
93 The values of kp, ki, and kd have slightly different interpretations depending
94 on whether the PID controller is a standard one, or an ideal/parallel one -
95 with the latter being the default.
96
97 By default, the PID controller computes the derivative as being the slope of
98 the line joining the value of the previous input to the value of the current
99 input. However if a better estimation can be determined for the derivative,
100 you can provide its value to the PID controller via the property supplied in
101 pvdot.
102
103 kp - Proportional constant, default value 0.
104 ki - Integrative constant, default value 0.
105 kd - Derivative constant, default value 0.
106 trigger - Property which is used to sense wind-up, optional. Most often, the
107 trigger will be driven by the "saturated" property of a particular
108 actuator. When the relevant actuator has reached it's limits (if
109 there are any, specified by the <clipto> element) the automatically
110 generated saturated property will be greater than zero (true). If
111 this property is used as the trigger for the integrator, the
112 integrator will not continue to integrate while the property is
113 still true (> 1), preventing wind-up.
114 The integrator can also be reset to 0.0 if the property is set to a
115 negative value.
116 pvdot - The property to be used as the process variable time derivative.
117
118 @author Jon S. Berndt
119 */
120
121 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 CLASS DECLARATION
123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
124
125 class FGPID : public FGFCSComponent
126 {
127 public:
128 FGPID(FGFCS* fcs, Element* element);
129 ~FGPID();
130
131 bool Run (void) override;
132 void ResetPastStates(void) override;
133
134 /// These define the indices use to select the various integrators.
135 enum eIntegrateType {eNone = 0, eRectEuler, eTrapezoidal, eAdamsBashforth2,
136 eAdamsBashforth3};
137
138 void SetInitialOutput(double val) {
139 I_out_total = val;
140 Output = val;
141 }
142
143 private:
144 double I_out_total;
145 double Input_prev, Input_prev2;
146
147 bool IsStandard;
148
149 eIntegrateType IntType;
150
151 FGParameter *Kp, *Ki, *Kd, *Trigger, *ProcessVariableDot;
152
153 void bind(Element* el) override;
154 void Debug(int from) override;
155 };
156 }
157 #endif