@@ -23,6 +23,7 @@ namespace etrobocon2025_test {
2323 EXPECT_DOUBLE_EQ (expected_ki, actualPidGain.ki );
2424 EXPECT_DOUBLE_EQ (expected_kd, actualPidGain.kd );
2525 }
26+
2627 // PidGainの0のゲインがそのまま格納されるかをテスト
2728 TEST (PidGainTest, PidGainZero)
2829 {
@@ -306,7 +307,7 @@ namespace etrobocon2025_test {
306307 // 積分項がmaxIntegralで正しく制限されているかをテスト
307308 TEST (PidTest, CalculatePidIntegralUpperBound)
308309 {
309- Pid pid (0.0 , 1.0 , 0.0 , 100 , 50 , -100.0 ); // maxIntegral = 50
310+ Pid pid (0.0 , 1.0 , 0.0 , 100 , 50 , -100.0 ); // maxIntegral = 50.0
310311 double currentValue = 0.0 ;
311312 for (int i = 0 ; i < 500 ; ++i) { // 5秒間の累積
312313 pid.calculatePid (currentValue);
@@ -319,7 +320,7 @@ namespace etrobocon2025_test {
319320 // 積分項がminIntegralで正しく制限されているかをテスト
320321 TEST (PidTest, CalculatePidIntegralLowerBound)
321322 {
322- Pid pid (0.0 , 1.0 , 0.0 , -100 , 100.0 , -50.0 ); // minIntegral = -50
323+ Pid pid (0.0 , 1.0 , 0.0 , -100 , 100.0 , -50.0 ); // minIntegral = -50.0
323324 double currentValue = 0.0 ;
324325 for (int i = 0 ; i < 500 ; ++i) { // 5秒間の累積
325326 pid.calculatePid (currentValue);
@@ -329,4 +330,30 @@ namespace etrobocon2025_test {
329330 EXPECT_DOUBLE_EQ (output, expected);
330331 }
331332
333+ // 積分項の制限をしない時積分項がmaxIntegral = 100.0で正しく制限されているかをテスト
334+ TEST (PidTest, CalculatePidNotSetIntegralUpperBound)
335+ {
336+ Pid pid (0.0 , 1.0 , 0.0 , 100 ); // maxIntegral = 100.0
337+ double currentValue = 0.0 ;
338+ for (int i = 0 ; i < 500 ; ++i) { // 5秒間の累積
339+ pid.calculatePid (currentValue);
340+ }
341+ double output = pid.calculatePid (currentValue);
342+ double expected = 100.0 ;
343+ EXPECT_DOUBLE_EQ (output, expected);
344+ }
345+
346+ // 積分項の制限をしない時積分項がminIntegral = -100.0で正しく制限されているかをテスト
347+ TEST (PidTest, CalculatePidNotSetIntegralLowerBound)
348+ {
349+ Pid pid (0.0 , 1.0 , 0.0 , -100 ); // minIntegral = -100.0
350+ double currentValue = 0.0 ;
351+ for (int i = 0 ; i < 500 ; ++i) { // 5秒間の累積
352+ pid.calculatePid (currentValue);
353+ }
354+ double output = pid.calculatePid (currentValue);
355+ double expected = -100.0 ;
356+ EXPECT_DOUBLE_EQ (output, expected);
357+ }
358+
332359} // namespace etrobocon2025_test
0 commit comments