YARP
Yet Another Robot Platform
ControlBoardPid.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
11 
12 using namespace yarp::dev;
13 
14 Pid::Pid(double p, double d, double i,
15  double intm, double sc, double omax):
16  kp(p),
17  kd(d),
18  ki(i),
19  max_int(intm),
20  scale(sc),
21  max_output(omax),
22  offset(0),
23  stiction_up_val(0),
24  stiction_down_val(0),
25  kff(0)
26 {}
27 
28 Pid::Pid(double p, double d, double i,
29  double intm, double sc, double omax, double st_up, double st_down, double ff) :
30  kp(p),
31  kd(d),
32  ki(i),
33  max_int(intm),
34  scale(sc),
35  max_output(omax),
36  offset(0),
37  stiction_up_val(st_up),
38  stiction_down_val(st_down),
39  kff(ff)
40 {}
41 
42 Pid::~Pid() = default;
43 
45 {
46  clear();
47 }
48 
49 void Pid::clear()
50 {
51  kp = 0;
52  kd = 0;
53  ki = 0;
54  scale = 0;
55  max_int = 0;
56  max_output = 0;
57  offset = 0;
58  stiction_up_val = 0;
60  kff = 0;
61 }
62 
63 void Pid::setKp(double p)
64 {
65  kp=p;
66 }
67 
68 void Pid::setKi(double i)
69 {
70  ki=i;
71 }
72 
73 void Pid::setKd(double d)
74 {
75  kd=d;
76 }
77 
78 void Pid::setMaxInt(double m)
79 {
80  max_int=m;
81 }
82 
83 void Pid::setScale(double sc)
84 {
85  scale=sc;
86 }
87 
88 void Pid::setMaxOut(double m)
89 {
90  max_output=m;
91 }
92 
93 void Pid::setOffset(double o)
94 {
95  offset=o;
96 }
97 
98 void Pid::setStictionValues(double up_value, double down_value)
99 {
100  stiction_up_val=up_value;
101  stiction_down_val=down_value;
102 }
103 
104 void Pid::setKff(double ff)
105 {
106  kff=ff;
107 }
108 
109 bool Pid::operator==(const yarp::dev::Pid &p) const
110 {
111 
112  if(kp != p.kp)
113  return false;
114 
115  if(ki != p.ki)
116  return false;
117 
118  if(kd != p.kd)
119  return false;
120 
121  if(max_output != p.max_output)
122  return false;
123 
124  if(max_int != p.max_int)
125  return false;
126 
127  if(kff != p.kff)
128  return false;
129 
130  if(offset != p.offset)
131  return false;
132 
133  if(scale != p.scale)
134  return false;
135 
137  return false;
138 
140  return false;
141 
142  return true;
143 
144 }
yarp::dev::Pid::stiction_up_val
double stiction_up_val
up stiction offset added to the pid output
Definition: ControlBoardPid.h:38
yarp::dev::Pid::Pid
Pid()
Default Constructor.
Definition: ControlBoardPid.cpp:44
yarp::dev::Pid::max_output
double max_output
max output
Definition: ControlBoardPid.h:36
yarp::dev::Pid::scale
double scale
scale for the pid output
Definition: ControlBoardPid.h:35
yarp::dev::Pid::ki
double ki
integrative gain
Definition: ControlBoardPid.h:33
yarp::dev::Pid::setMaxInt
void setMaxInt(double m)
Set max threshold for the integrative part.
Definition: ControlBoardPid.cpp:78
ControlBoardInterfaces.h
define control board standard interfaces
yarp::dev::Pid::setMaxOut
void setMaxOut(double m)
Set max output value for the pid.
Definition: ControlBoardPid.cpp:88
yarp::dev::Pid::setScale
void setScale(double sc)
Set output scale for the pid.
Definition: ControlBoardPid.cpp:83
yarp::dev
An interface for the device drivers.
Definition: audioBufferSizeData.cpp:17
yarp::dev::Pid::setKi
void setKi(double i)
Set integrative gain.
Definition: ControlBoardPid.cpp:68
yarp::dev::Pid::setKp
void setKp(double p)
Set proportional gain.
Definition: ControlBoardPid.cpp:63
yarp::dev::Pid::offset
double offset
pwm offset added to the pid output
Definition: ControlBoardPid.h:37
yarp::dev::Pid::max_int
double max_int
saturation threshold for the integrator
Definition: ControlBoardPid.h:34
yarp::dev::Pid::operator==
bool operator==(const yarp::dev::Pid &p) const
return true if all params are equal
Definition: ControlBoardPid.cpp:109
yarp::dev::Pid::kd
double kd
derivative gain
Definition: ControlBoardPid.h:32
yarp::dev::Pid::kp
double kp
proportional gain
Definition: ControlBoardPid.h:31
yarp::dev::Pid::kff
double kff
feedforward gain
Definition: ControlBoardPid.h:40
yarp::dev::Pid::~Pid
~Pid()
Destructor.
yarp::dev::Pid::stiction_down_val
double stiction_down_val
down stiction offset added to the pid output
Definition: ControlBoardPid.h:39
yarp::dev::Pid::setOffset
void setOffset(double o)
Set offset value for the pid.
Definition: ControlBoardPid.cpp:93
yarp::dev::Pid::setKff
void setKff(double Kff)
Set the feedforward gain for the pid.
Definition: ControlBoardPid.cpp:104
yarp::dev::Pid::clear
void clear()
Set all pid parameters to zero.
Definition: ControlBoardPid.cpp:49
yarp::dev::Pid
Contains the parameters for a PID.
Definition: ControlBoardPid.h:29
yarp::dev::Pid::setKd
void setKd(double d)
Set derivative gain.
Definition: ControlBoardPid.cpp:73
yarp::dev::Pid::setStictionValues
void setStictionValues(double up_value, double down_value)
Set the two stiction values for the pid.
Definition: ControlBoardPid.cpp:98