ArPiRobot-CoreLib C++
C++ library for ArPiRobot robots
include
arpirobot
core
control
PID.hpp
1
/*
2
* Copyright 2022 Marcus Behel
3
*
4
* This file is part of ArPiRobot-CoreLib.
5
*
6
* ArPiRobot-CoreLib is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* ArPiRobot-CoreLib is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with ArPiRobot-CoreLib. If not, see <https://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
namespace
arpirobot
{
23
29
class
PID
{
30
public
:
31
42
PID
(
double
kp = 0,
double
ki = 0,
double
kd = 0,
43
double
kf = 0,
double
min = -1.0,
double
max = 1.0);
44
50
double
getKp
();
51
57
void
setKp
(
double
kp);
58
64
double
getKi
();
65
71
void
setKi
(
double
ki);
72
78
double
getKd
();
79
85
void
setKd
(
double
kd);
86
92
double
getKf
();
93
99
void
setKf
(
double
kf);
100
106
double
getMin
();
107
113
void
setMin
(
double
min);
114
120
double
getMax
();
121
127
void
setMax
(
double
max);
128
129
135
double
getSetpoint
();
136
142
void
setSetpoint
(
double
setpoint);
143
149
void
reset
();
150
157
double
getOutput
(
double
currentPv);
158
159
160
private
:
161
double
kp, ki, kd, kf;
// Gains (P, I, D, and feedforward)
162
double
min, max;
// Values to cap PID output at
163
double
setpoint = 0;
// Current setpoint
164
165
double
integral = 0;
// Current accumulated (integral) value
166
double
lastError = 0;
// Previous error used in derivative value calculation
167
};
168
169
}
arpirobot::PID
Definition:
PID.hpp:29
arpirobot::PID::setSetpoint
void setSetpoint(double setpoint)
arpirobot::PID::getKd
double getKd()
arpirobot::PID::getMin
double getMin()
arpirobot::PID::setMax
void setMax(double max)
arpirobot::PID::setMin
void setMin(double min)
arpirobot::PID::setKi
void setKi(double ki)
arpirobot::PID::reset
void reset()
arpirobot::PID::getKf
double getKf()
arpirobot::PID::setKp
void setKp(double kp)
arpirobot::PID::getKp
double getKp()
arpirobot::PID::getOutput
double getOutput(double currentPv)
arpirobot::PID::getSetpoint
double getSetpoint()
arpirobot::PID::getKi
double getKi()
arpirobot::PID::setKf
void setKf(double kf)
arpirobot::PID::getMax
double getMax()
arpirobot::PID::PID
PID(double kp=0, double ki=0, double kd=0, double kf=0, double min=-1.0, double max=1.0)
arpirobot::PID::setKd
void setKd(double kd)
arpirobot
Definition:
ArduinoDevice.hpp:27
Generated by
1.9.1