JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGPID.h
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, 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 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 Lesser General Public License for more
17  details.
18 
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.
22 
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.
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 DEFINITIONS
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46 
47 #define ID_PID "$Id: FGPID.h,v 1.16 2014/01/02 21:58:42 bcoconni Exp $"
48 
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 FORWARD DECLARATIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52 
53 namespace JSBSim {
54 
55 class FGFCS;
56 class Element;
57 
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS DOCUMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 
122 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
123 CLASS DECLARATION
124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
125 
126 class FGPID : public FGFCSComponent
127 {
128 public:
129  FGPID(FGFCS* fcs, Element* element);
130  ~FGPID();
131 
132  bool Run (void);
133  void ResetPastStates(void);
134 
136  enum eIntegrateType {eNone = 0, eRectEuler, eTrapezoidal, eAdamsBashforth2, eAdamsBashforth3};
137 
138  void SetInitialOutput(double val) {
139  I_out_total = val;
140  Output = val;
141  }
142 
143 private:
144  double Kp, Ki, Kd;
145  double I_out_total;
146  double Input_prev, Input_prev2;
147  double KpPropertySign;
148  double KiPropertySign;
149  double KdPropertySign;
150 
151  bool IsStandard;
152 
153  eIntegrateType IntType;
154 
155  FGPropertyNode_ptr Trigger;
156  FGPropertyNode_ptr KpPropertyNode;
157  FGPropertyNode_ptr KiPropertyNode;
158  FGPropertyNode_ptr KdPropertyNode;
159  FGPropertyNode_ptr ProcessVariableDot;
160 
161  void Debug(int from);
162 };
163 }
164 #endif
Encapsulates a PID control component for the flight control system.
Definition: FGPID.h:126
eIntegrateType
These define the indices use to select the various integrators.
Definition: FGPID.h:136
Encapsulates the Flight Control System (FCS) functionality.
Definition: FGFCS.h:193
Base class for JSBSim Flight Control System Components.