@@ -24,18 +24,18 @@ TEST(TestPID, calculate_pid_output)
24
24
const double dt = 1.0 ;
25
25
double target = 10.0 ;
26
26
double current = 0.0 ;
27
- bool erase_integral = true ;
27
+ bool enable_integration = false ;
28
28
29
29
PIDController pid;
30
30
31
31
// Cannot calculate before initializing gains and limits
32
- EXPECT_THROW (pid.calculate (0.0 , dt, erase_integral , contributions), std::runtime_error);
32
+ EXPECT_THROW (pid.calculate (0.0 , dt, enable_integration , contributions), std::runtime_error);
33
33
34
34
pid.setGains (1.0 , 1.0 , 1.0 );
35
35
pid.setLimits (10.0 , 0.0 , 10.0 , 0.0 , 10.0 , 0.0 , 10.0 , 0.0 );
36
36
double error = target - current;
37
37
while (current != target) {
38
- current = pid.calculate (error, dt, erase_integral , contributions);
38
+ current = pid.calculate (error, dt, enable_integration , contributions);
39
39
EXPECT_EQ (contributions[0 ], 0.0 ); // integral is erased
40
40
EXPECT_EQ (contributions[1 ], 0.0 ); // double integral is erased
41
41
EXPECT_EQ (contributions[2 ], error);
@@ -45,22 +45,22 @@ TEST(TestPID, calculate_pid_output)
45
45
46
46
pid.setGains (100.0 , 100.0 , 100.0 );
47
47
pid.setLimits (10.0 , -10.0 , 10.0 , -10.0 , 10.0 , -10.0 , 10.0 , -10.0 );
48
- erase_integral = false ;
48
+ enable_integration = true ;
49
49
50
50
// High errors to force each component to its upper limit
51
- EXPECT_EQ (pid.calculate (0.0 , dt, erase_integral , contributions), 0.0 );
51
+ EXPECT_EQ (pid.calculate (0.0 , dt, enable_integration , contributions), 0.0 );
52
52
for (double error = 100.0 ; error < 1000.0 ; error += 100.0 ) {
53
- EXPECT_EQ (pid.calculate (error, dt, erase_integral , contributions), 10.0 );
53
+ EXPECT_EQ (pid.calculate (error, dt, enable_integration , contributions), 10.0 );
54
54
EXPECT_EQ (contributions[0 ], 10.0 ); // integral is not erased
55
55
EXPECT_EQ (contributions[1 ], 10.0 ); // double integral is not erased
56
56
EXPECT_EQ (contributions[2 ], 10.0 );
57
57
}
58
58
pid.reset ();
59
59
60
60
// Low errors to force each component to its lower limit
61
- EXPECT_EQ (pid.calculate (0.0 , dt, erase_integral , contributions), 0.0 );
61
+ EXPECT_EQ (pid.calculate (0.0 , dt, enable_integration , contributions), 0.0 );
62
62
for (double error = -100.0 ; error > -1000.0 ; error -= 100.0 ) {
63
- EXPECT_EQ (pid.calculate (error, dt, erase_integral , contributions), -10.0 );
63
+ EXPECT_EQ (pid.calculate (error, dt, enable_integration , contributions), -10.0 );
64
64
EXPECT_EQ (contributions[0 ], -10.0 ); // integral is not erased
65
65
EXPECT_EQ (contributions[1 ], -10.0 ); // double integral is not erased
66
66
EXPECT_EQ (contributions[2 ], -10.0 );
0 commit comments