From 91c70daf5b36c62d3293e6609ca417d5288ce7bc Mon Sep 17 00:00:00 2001 From: James Kuszmaul Date: Thu, 20 Nov 2014 16:39:00 -0500 Subject: [PATCH] Tried to improve reliability of a couple of unit tests. Change-Id: I45307da855808e85c8f9b9958c7590d60636f8e9 --- .../src/TiltPanCameraTest.cpp | 12 ++++++++---- .../main/java/edu/wpi/first/wpilibj/GyroTest.java | 13 +++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/wpilibc/wpilibC++IntegrationTests/src/TiltPanCameraTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/TiltPanCameraTest.cpp index 9e9f2839f9..5bd56b8c4a 100644 --- a/wpilibc/wpilibC++IntegrationTests/src/TiltPanCameraTest.cpp +++ b/wpilibc/wpilibC++IntegrationTests/src/TiltPanCameraTest.cpp @@ -13,9 +13,9 @@ static constexpr double kServoResetTime = 2.0; static constexpr double kTestAngle = 180.0; -static constexpr double kTiltSetpoint0 = 0.16; -static constexpr double kTiltSetpoint45 = 0.385; -static constexpr double kTiltSetpoint90 = 0.61; +static constexpr double kTiltSetpoint0 = 0.22; +static constexpr double kTiltSetpoint45 = 0.45; +static constexpr double kTiltSetpoint90 = 0.68; static constexpr double kTiltTime = 1.0; static constexpr double kAccelerometerTolerance = 0.2; @@ -73,9 +73,13 @@ TEST_F(TiltPanCameraTest, DefaultGyroAngle) { * Test if the servo turns 180 degrees and the gyroscope measures this angle */ TEST_F(TiltPanCameraTest, GyroAngle) { + // Make sure that the gyro doesn't get jerked when the servo goes to zero. + m_pan->SetAngle(0.0); + Wait(0.25); + m_gyro->Reset(); + for(int i = 0; i < 1800; i++) { m_pan->SetAngle(i / 10.0); - Wait(0.001); } diff --git a/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/GyroTest.java b/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/GyroTest.java index ed58142a06..45cd063ced 100644 --- a/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/GyroTest.java +++ b/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/GyroTest.java @@ -61,14 +61,11 @@ public class GyroTest extends AbstractComsSetup { tpcam.getPan().setAngle(45); Timer.delay(.1); } + + Timer.delay(0.5); //Reset for setup tpcam.getGyro().reset(); - - //Prevent drift - for(int i = 0; i < 10; i++) { - tpcam.getPan().setAngle(45); - Timer.delay(.1); - } + Timer.delay(0.5); //Perform test for(int i = 450; i < 1350; i++) { @@ -88,6 +85,10 @@ public class GyroTest extends AbstractComsSetup { @Test public void testDeviationOverTime(){ + // Make sure that the test isn't influenced by any previous motions. + Timer.delay(0.25); + tpcam.getGyro().reset(); + Timer.delay(0.25); double angle = tpcam.getGyro().getAngle(); assertEquals(errorMessage(angle, 0), 0, angle, .5); Timer.delay(5);