@@ -29,14 +29,14 @@ TEST(TestPID, calculate_pid_output)
29
29
PIDController pid;
30
30
31
31
// Cannot calculate before initializing gains and limits
32
- EXPECT_THROW (pid.calculate (0.0 , dt, enable_integration, contributions), std::runtime_error);
32
+ EXPECT_THROW (pid.calculate (0.0 , 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
double prev_error = error;
38
38
while (current != target) {
39
- current = pid.calculate (error, dt, enable_integration, contributions);
39
+ current = pid.calculate (error, error, dt, enable_integration, contributions);
40
40
EXPECT_EQ (contributions[0 ], error);
41
41
EXPECT_EQ (contributions[1 ], 0.0 ); // integration is deactivated
42
42
EXPECT_EQ (contributions[2 ], error - prev_error);
@@ -50,18 +50,18 @@ TEST(TestPID, calculate_pid_output)
50
50
enable_integration = true ;
51
51
52
52
// High errors to force each component to its upper limit
53
- EXPECT_EQ (pid.calculate (0.0 , dt, enable_integration, contributions), 0.0 );
53
+ EXPECT_EQ (pid.calculate (0.0 , 0.0 , dt, enable_integration, contributions), 0.0 );
54
54
for (double error = 100.0 ; error < 1000.0 ; error += 100.0 ) {
55
- EXPECT_EQ (pid.calculate (error, dt, enable_integration, contributions), 10.0 );
55
+ EXPECT_EQ (pid.calculate (error, error, dt, enable_integration, contributions), 10.0 );
56
56
EXPECT_EQ (contributions[0 ], 10.0 );
57
57
EXPECT_EQ (contributions[1 ], 10.0 ); // integration is activated
58
58
EXPECT_EQ (contributions[2 ], 10.0 );
59
59
}
60
60
61
61
// Low errors to force each component to its lower limit
62
- EXPECT_EQ (pid.calculate (0.0 , dt, enable_integration, contributions), 0.0 );
62
+ EXPECT_EQ (pid.calculate (0.0 , 0.0 , dt, enable_integration, contributions), 0.0 );
63
63
for (double error = -100.0 ; error > -1000.0 ; error -= 100.0 ) {
64
- EXPECT_EQ (pid.calculate (error, dt, enable_integration, contributions), -10.0 );
64
+ EXPECT_EQ (pid.calculate (error, error, dt, enable_integration, contributions), -10.0 );
65
65
EXPECT_EQ (contributions[0 ], -10.0 );
66
66
EXPECT_EQ (contributions[1 ], -10.0 ); // integration is activated
67
67
EXPECT_EQ (contributions[2 ], -10.0 );
0 commit comments