Tried to improve reliability of a couple of unit tests.

Change-Id: I45307da855808e85c8f9b9958c7590d60636f8e9
This commit is contained in:
James Kuszmaul
2014-11-20 16:39:00 -05:00
parent 99dc3c90ed
commit 91c70daf5b
2 changed files with 15 additions and 10 deletions

View File

@@ -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);
}

View File

@@ -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);