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 }
define control board standard interfaces
Contains the parameters for a PID.
double kd
derivative gain
double scale
scale for the pid output
double offset
pwm offset added to the pid output
double stiction_down_val
down stiction offset added to the pid output
void clear()
Set all pid parameters to zero.
double stiction_up_val
up stiction offset added to the pid output
double max_output
max output
void setKp(double p)
Set proportional gain.
~Pid()
Destructor.
Pid()
Default Constructor.
void setMaxOut(double m)
Set max output value for the pid.
double kff
feedforward gain
void setOffset(double o)
Set offset value for the pid.
void setKi(double i)
Set integrative gain.
double ki
integrative gain
double max_int
saturation threshold for the integrator
void setKff(double Kff)
Set the feedforward gain for the pid.
void setStictionValues(double up_value, double down_value)
Set the two stiction values for the pid.
void setScale(double sc)
Set output scale for the pid.
double kp
proportional gain
bool operator==(const yarp::dev::Pid &p) const
return true if all params are equal
void setKd(double d)
Set derivative gain.
void setMaxInt(double m)
Set max threshold for the integrative part.
An interface for the device drivers.