diff --git a/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java b/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java index ad4e8c1b60..e1f647041d 100644 --- a/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java +++ b/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java @@ -107,7 +107,7 @@ public class MotorEncoderTest extends AbstractComsSetup { assertTrue(me.getType() + " Encoder not incremented: start: " + startValue + "; current: " + currentValue, startValue < currentValue); - + } /** @@ -172,7 +172,7 @@ public class MotorEncoderTest extends AbstractComsSetup { public void testPIDController() { PIDController pid = new PIDController(0.003, 0.001, 0, me.getEncoder(), me.getMotor()); - pid.setAbsoluteTolerance(15); + pid.setAbsoluteTolerance(50); pid.setOutputRange(-0.2, 0.2); pid.setSetpoint(2500); diff --git a/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java b/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java index 6e3345210c..e5a9115fb7 100644 --- a/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java +++ b/wpilibj/wpilibJavaIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java @@ -43,21 +43,21 @@ import edu.wpi.first.wpilibj.test.TestBench; public class PIDTest extends AbstractComsSetup { private static final Logger logger = Logger.getLogger(PIDTest.class.getName()); private NetworkTable table; - - private static final double absoluteTollerance = 20; - private static final double outputRange = 0.3; - + + private static final double absoluteTolerance = 50; + private static final double outputRange = 0.3; + private PIDController controller = null; private static MotorEncoderFixture me = null; - + private final Double k_p, k_i, k_d; - + @Override protected Logger getClassLogger(){ return logger; } - + public PIDTest(Double p, Double i, Double d, MotorEncoderFixture mef){ logger.fine("Constructor with: " + mef.getType()); if(PIDTest.me != null && !PIDTest.me.equals(mef)) PIDTest.me.teardown(); @@ -66,8 +66,8 @@ public class PIDTest extends AbstractComsSetup { this.k_i = i; this.k_d = d; } - - + + @Parameters public static Collection generateData(){ //logger.fine("Loading the MotorList"); @@ -124,17 +124,17 @@ public class PIDTest extends AbstractComsSetup { controller = null; me.reset(); } - - private void setupAbsoluteTollerance(){ - controller.setAbsoluteTolerance(absoluteTollerance); + + private void setupAbsoluteTolerance(){ + controller.setAbsoluteTolerance(absoluteTolerance); } private void setupOutputRange(){ controller.setOutputRange(-outputRange, outputRange); } - + @Test public void testInitialSettings(){ - setupAbsoluteTollerance(); + setupAbsoluteTolerance(); setupOutputRange(); double setpoint = 2500.0; controller.setSetpoint(setpoint); @@ -146,10 +146,10 @@ public class PIDTest extends AbstractComsSetup { assertEquals(setpoint, table.getNumber("setpoint"), 0); assertFalse(table.getBoolean("enabled")); } - + @Test public void testRestartAfterEnable(){ - setupAbsoluteTollerance(); + setupAbsoluteTolerance(); setupOutputRange(); double setpoint = 2500.0; controller.setSetpoint(setpoint); @@ -163,10 +163,10 @@ public class PIDTest extends AbstractComsSetup { assertFalse(controller.isEnable()); assertEquals(0, me.getMotor().get(), 0); } - + @Test public void testSetSetpoint(){ - setupAbsoluteTollerance(); + setupAbsoluteTolerance(); setupOutputRange(); Double setpoint = 2500.0; controller.disable(); @@ -175,27 +175,27 @@ public class PIDTest extends AbstractComsSetup { assertEquals("Did not correctly set set-point",setpoint, new Double(controller.getSetpoint())); } - @Test (timeout = 15000) + @Test (timeout = 10000) public void testRotateToTarget() { - setupAbsoluteTollerance(); + setupAbsoluteTolerance(); setupOutputRange(); double setpoint = 2500.0; assertEquals(pidData() + "did not start at 0", 0, controller.get(), 0); controller.setSetpoint(setpoint); assertEquals(pidData() +"did not have an error of " + setpoint, setpoint, controller.getError(), 0); controller.enable(); - Timer.delay(10); + Timer.delay(5); controller.disable(); assertTrue(pidData() + "Was not on Target. Controller Error: " + controller.getError(), controller.onTarget()); } - + private String pidData(){ return me.getType() + " PID {P:" +controller.getP() + " I:" + controller.getI() + " D:" + controller.getD() +"} "; } - - + + @Test(expected = RuntimeException.class) - public void testOnTargetNoTolleranceSet(){ + public void testOnTargetNoToleranceSet(){ setupOutputRange(); controller.onTarget(); }