-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasicpid.cpp
48 lines (33 loc) · 1.19 KB
/
basicpid.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "basicpid.hpp"
namespace terraclear
{
basicpid::basicpid(double Kp, double Ki, double Kd, uint32_t interval_ms)
{
}
basicpid::~basicpid()
{
}
double basicpid::domain_transform(double from_value, double from_min, double from_max, double to_min, double to_max)
{
//constrain input value to fit between from_max and from_min
double from_constrained = std::min(std::max(from_min, from_value), from_max);
//rebase input and output values to be a zero based scale.
double from_scale = from_max - from_min;
double to_scale = to_max - to_min;
//rebase the constrained value and prevent a divide by zero if from_value was constrained to from_min
double from_rebased = (from_constrained <= from_min) ? from_min : from_constrained - from_min;
//do the [from -> to] domain transform..
double retval = ((from_rebased / from_scale) * to_scale) + to_min;
return retval;
}
void basicpid::start()
{
}
void basicpid::stop()
{
}
double basicpid::compute(double Input, double Setpoint)
{
return 0;
}
}