NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgPIDController.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
7  * under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * http://www.apache.org/licenses/LICENSE-2.0.
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15  * either express or implied. See the License for the specific language
16  * governing permissions and limitations under the License.
17 */
18 
19 #ifndef TG_PID_CONTROLLER_H
20 #define TG_PID_CONTROLLER_H
21 
30 #include "tgBasicController.h"
31 
32 // Forward declarations
33 class tgControllable;
34 
42 {
43 public:
44 
45  struct Config
46  {
56  Config(double p = 1.0,
57  double i = 0.0,
58  double d = 0.0,
59  bool tensControl = false,
60  double setPoint = 0.0);
61 
68  const double kP;
69 
76  const double kI;
77 
84  const double kD;
85 
90  const double startingSetPoint;
91  };
92 
102 
107  virtual ~tgPIDController();
108 
115  virtual void control(double dt);
116 
126  virtual void control(double dt, double setPoint, double sensorData);
127 
133  virtual void setSensorData(double sensorData);
134 
136 
137 private:
141  double m_sensorData;
142 
147  double m_prevError;
148 
152  double m_intError;
153 
157  const tgPIDController::Config m_config;
158 };
159 
160 #endif // TG_PID_CONTROLLER_H
161 
Config(double p=1.0, double i=0.0, double d=0.0, bool tensControl=false, double setPoint=0.0)
virtual void control(double dt)
virtual ~tgPIDController()
Definition of the tgBasicController base class.
virtual void setSensorData(double sensorData)
tgPIDController(tgControllable *controllable, tgPIDController::Config config)
const double startingSetPoint