pid.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2014, Fetch Robotics Inc.
5  * Copyright (c) 2013, Unbounded Robotics Inc.
6  * Copyright (c) 2008, Willow Garage, Inc.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Unbounded Robotics nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *********************************************************************/
36 
37 #ifndef ROBOT_CONTROLLERS_PID_H
38 #define ROBOT_CONTROLLERS_PID_H
39 
40 #include <ros/ros.h>
41 
42 namespace robot_controllers
43 {
44 
45 class PID
46 {
47 public:
56  PID(double p, double i, double d, double i_max, double i_min);
57 
59  PID();
60 
62  bool init(const ros::NodeHandle &nh);
63 
65  void reset();
66 
75  double update(double error, double dt);
76 
84  double update(double error, double error_dot, double dt);
85 
86 protected:
87 
92  bool checkGains();
93 
95  double p_gain_;
97  double i_gain_;
99  double d_gain_;
101  double i_max_, i_min_;
102 
104  double i_term_;
105 
107  double error_last_;
108 };
109 
110 } // namespace robot_controllers
111 
112 #endif // ROBOT_CONTROLLERS_PID_H
d
PID()
Constructor. Starts all gains and limits at zero.
Definition: pid.cpp:58
double i_term_
integral wind-up term
Definition: pid.h:104
bool checkGains()
Checks and fixes gain settings.
Definition: pid.cpp:92
double error_last_
Last error value, used for calculating error_dot when not provided.
Definition: pid.h:107
double update(double error, double dt)
Run PID calculation and return control result.
Definition: pid.cpp:146
double i_max_
integral gain min and max limits
Definition: pid.h:101
void reset()
Reset integral wind-up term.
Definition: pid.cpp:140
double p_gain_
proportial gain
Definition: pid.h:95
double i_gain_
integral gain
Definition: pid.h:97
bool init(const ros::NodeHandle &nh)
initialize gain settings from ROS parameter values
Definition: pid.cpp:68
double d_gain_
derivative gain
Definition: pid.h:99


robot_controllers
Author(s): Michael Ferguson
autogenerated on Sun Sep 27 2020 03:22:39