YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ControlBoardPid.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
8
9using namespace yarp::dev;
10
11Pid::Pid(double p, double d, double i,
12 double intm, double sc, double omax):
13 PidGainsData(p, d, i, intm, sc, omax, 0.0, 0.0 ,0.0, 0.0)
14{}
15
16Pid::Pid(double p, double d, double i,
17 double intm, double sc, double omax, double st_up, double st_down, double ff) :
18 PidGainsData(p, d, i, intm, sc, omax, 0.0, st_up, st_down, ff)
19{}
20
21Pid::~Pid() = default;
22
24{
25 clear();
26}
27
29{
30 kp = 0;
31 kd = 0;
32 ki = 0;
33 scale = 0;
34 max_int = 0;
35 max_output = 0;
36 offset = 0;
39 kff = 0;
40}
41
42void Pid::setKp(double p)
43{
44 kp=p;
45}
46
47void Pid::setKi(double i)
48{
49 ki=i;
50}
51
52void Pid::setKd(double d)
53{
54 kd=d;
55}
56
57void Pid::setMaxInt(double m)
58{
59 max_int=m;
60}
61
62void Pid::setScale(double sc)
63{
64 scale=sc;
65}
66
67void Pid::setMaxOut(double m)
68{
69 max_output=m;
70}
71
72void Pid::setOffset(double o)
73{
74 offset=o;
75}
76
77void Pid::setStictionValues(double up_value, double down_value)
78{
79 stiction_up_val=up_value;
80 stiction_down_val=down_value;
81}
82
83void Pid::setKff(double ff)
84{
85 kff=ff;
86}
87
88bool Pid::operator==(const yarp::dev::Pid &p) const
89{
90
91 if (kp != p.kp) {
92 return false;
93 }
94
95 if (ki != p.ki) {
96 return false;
97 }
98
99 if (kd != p.kd) {
100 return false;
101 }
102
103 if (max_output != p.max_output) {
104 return false;
105 }
106
107 if (max_int != p.max_int) {
108 return false;
109 }
110
111 if (kff != p.kff) {
112 return false;
113 }
114
115 if (offset != p.offset) {
116 return false;
117 }
118
119 if (scale != p.scale) {
120 return false;
121 }
122
124 return false;
125 }
126
128 return false;
129 }
130
131 return true;
132}
defines yarp::dev::Pid datatype
double ki
integrative gain
double scale
scale for the pid output
double kp
proportional gain
double max_output
max output
double stiction_down_val
down stiction offset added to the pid output
double kff
feedforward gain
double stiction_up_val
up stiction offset added to the pid output
double kd
derivative gain
double offset
pwm offset added to the pid output
double max_int
saturation threshold for the integrator
Contains the parameters for a PID.
void clear()
Set all pid parameters to zero.
void setKp(double p)
Set proportional gain.
~Pid()
Destructor.
Pid()
Default Constructor.
void setMaxOut(double m)
Set max output value for the pid.
void setOffset(double o)
Set offset value for the pid.
void setKi(double i)
Set integrative gain.
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.
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.
For streams capable of holding different kinds of content, check what they actually have.