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 kp(p),
14 kd(d),
15 ki(i),
16 max_int(intm),
17 scale(sc),
18 max_output(omax),
19 offset(0),
20 stiction_up_val(0),
21 stiction_down_val(0),
22 kff(0)
23{}
24
25Pid::Pid(double p, double d, double i,
26 double intm, double sc, double omax, double st_up, double st_down, double ff) :
27 kp(p),
28 kd(d),
29 ki(i),
30 max_int(intm),
31 scale(sc),
32 max_output(omax),
33 offset(0),
34 stiction_up_val(st_up),
35 stiction_down_val(st_down),
36 kff(ff)
37{}
38
39Pid::~Pid() = default;
40
42{
43 clear();
44}
45
47{
48 kp = 0;
49 kd = 0;
50 ki = 0;
51 scale = 0;
52 max_int = 0;
53 max_output = 0;
54 offset = 0;
57 kff = 0;
58}
59
60void Pid::setKp(double p)
61{
62 kp=p;
63}
64
65void Pid::setKi(double i)
66{
67 ki=i;
68}
69
70void Pid::setKd(double d)
71{
72 kd=d;
73}
74
75void Pid::setMaxInt(double m)
76{
77 max_int=m;
78}
79
80void Pid::setScale(double sc)
81{
82 scale=sc;
83}
84
85void Pid::setMaxOut(double m)
86{
87 max_output=m;
88}
89
90void Pid::setOffset(double o)
91{
92 offset=o;
93}
94
95void Pid::setStictionValues(double up_value, double down_value)
96{
97 stiction_up_val=up_value;
98 stiction_down_val=down_value;
99}
100
101void Pid::setKff(double ff)
102{
103 kff=ff;
104}
105
106bool Pid::operator==(const yarp::dev::Pid &p) const
107{
108
109 if (kp != p.kp) {
110 return false;
111 }
112
113 if (ki != p.ki) {
114 return false;
115 }
116
117 if (kd != p.kd) {
118 return false;
119 }
120
121 if (max_output != p.max_output) {
122 return false;
123 }
124
125 if (max_int != p.max_int) {
126 return false;
127 }
128
129 if (kff != p.kff) {
130 return false;
131 }
132
133 if (offset != p.offset) {
134 return false;
135 }
136
137 if (scale != p.scale) {
138 return false;
139 }
140
142 return false;
143 }
144
146 return false;
147 }
148
149 return true;
150
151}
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.
For streams capable of holding different kinds of content, check what they actually have.
Definition jointData.cpp:13