diff --git a/src/org/impact2585/frc2016/systems/WheelSystem.java b/src/org/impact2585/frc2016/systems/WheelSystem.java index 1a6072e..7a8fd83 100644 --- a/src/org/impact2585/frc2016/systems/WheelSystem.java +++ b/src/org/impact2585/frc2016/systems/WheelSystem.java @@ -17,7 +17,7 @@ public class WheelSystem implements RobotSystem, Runnable{ private double currentRampForward; private double rotationValue; public static final double DEADZONE = 0.15; - public static final double RAMP = 0.5; + public static final double RAMP = 0.6; private InputMethod input; private boolean inverted; private boolean prevInvert; diff --git a/test/org/impact2585/frc2016/tests/WheelSystemTest.java b/test/org/impact2585/frc2016/tests/WheelSystemTest.java index 5fc1646..9caf52d 100644 --- a/test/org/impact2585/frc2016/tests/WheelSystemTest.java +++ b/test/org/impact2585/frc2016/tests/WheelSystemTest.java @@ -1,6 +1,5 @@ package org.impact2585.frc2016.tests; - import org.impact2585.frc2016.input.InputMethod; import org.impact2585.frc2016.systems.WheelSystem; import org.junit.Assert; @@ -17,8 +16,18 @@ public class WheelSystemTest { private double currentRampForward; private double rotate; private boolean invert; - - + + /** + * method to calculate the ramping + * @return correct ramping + */ + public double rampForward() { + double realRampForward = (currentRampForward - driveForward) * WheelSystem.RAMP + currentRampForward; + if (driveForward < WheelSystem.DEADZONE && driveForward > -WheelSystem.DEADZONE) + realRampForward = 0; + return -realRampForward; + } + /** * Initializes the test wheel system and input */ @@ -38,84 +47,111 @@ public void setUp() { */ @Test public void test() { - - //tests if the robot isn't moving at the start + + // tests if the robot isn't moving at the start + double ramp = rampForward(); + ramp = rampForward(); drivetrain.run(); Assert.assertTrue(currentRampForward == 0 && rotate == 0); - - //tests deadzone + + // tests deadzone driveForward = 0.14; rotate = 0.14; + ramp = rampForward(); drivetrain.run(); Assert.assertTrue(currentRampForward == 0 && rotate == 0); - - //tests forward driving + + // tests forward driving driveForward = -0.5; + ramp = rampForward(); drivetrain.run(); - Assert.assertTrue(-0.25 == currentRampForward && rotate == 0); - - //tests turning and if currentRampForward immediately goes to 0 if the input is 0 + Assert.assertTrue(ramp == currentRampForward && rotate == 0); + + // tests turning and if currentRampForward immediately goes to 0 if the input is 0 + rotate = 1; driveForward = 0; + ramp = rampForward(); drivetrain.run(); Assert.assertTrue(currentRampForward == 0 && rotate == 1); - - //tests turning and driving simultaneously + + + // tests turning and driving simultaneously rotate = 1; driveForward = 0.5; drivetrain.setCurrentRampForward(0); + ramp = rampForward(); drivetrain.run(); - Assert.assertTrue(currentRampForward == 0.25 && rotate == 1); - - //tests invert + Assert.assertTrue(currentRampForward == ramp && rotate == 1); + + // tests invert invert = true; rotate = -0.5; driveForward = 0.5; + ramp = rampForward(); drivetrain.run(); - Assert.assertTrue(currentRampForward == -0.125 && rotate == -0.5); - - - //tests if it does not invert if the button is still pressed + Assert.assertTrue(currentRampForward == ramp && rotate == -0.5); + + + // tests if it does not invert if the button is still pressed invert = true; rotate = -0.5; driveForward = 0.5; + drivetrain.setCurrentRampForward(0.5); + ramp = rampForward(); + drivetrain.setCurrentRampForward(-0.5); drivetrain.run(); - Assert.assertTrue(currentRampForward == -0.3125 && rotate == -0.5); - - //tests if drivetrain continues to be inverted + Assert.assertTrue(currentRampForward == ramp && rotate == -0.5); + + // tests if drivetrain continues to be inverted invert = false; rotate = -0.5; driveForward = 0.5; + drivetrain.setCurrentRampForward(0.5); + ramp = rampForward(); + drivetrain.setCurrentRampForward(-0.5); drivetrain.run(); - Assert.assertTrue(currentRampForward == -0.40625 && rotate == -0.5); - - //tests if it inverts to the original position + Assert.assertTrue(currentRampForward == ramp && rotate == -0.5); + + // tests if it inverts to the original position invert = true; rotate = 0.7; driveForward = 0.5; + drivetrain.setCurrentRampForward(0.5); + ramp = rampForward(); + drivetrain.setCurrentRampForward(0.5); drivetrain.run(); - Assert.assertTrue(currentRampForward == 0.046875 && rotate == 0.7); - + Assert.assertTrue(currentRampForward == -ramp && rotate == 0.7); + // see if movement and rotation go back to 0 again rotate = driveForward = 0; + drivetrain.setCurrentRampForward(0.5); + ramp = rampForward(); + drivetrain.setCurrentRampForward(0.5); drivetrain.run(); - Assert.assertTrue(currentRampForward == 0 && rotate == 0); + Assert.assertTrue(currentRampForward == ramp && rotate == 0); } - + /** * testable version of wheelsystem */ private class TestWheelSystem extends WheelSystem { - /* (non-Javadoc) - * @see org.impact2585.frc2016.systems.WheelSystem#setInput(org.impact2585.frc2016.input.InputMethod) + /* + * (non-Javadoc) + * + * @see + * org.impact2585.frc2016.systems.WheelSystem#setInput(org.impact2585. + * frc2016.input.InputMethod) */ @Override protected synchronized void setInput(InputMethod controller) { super.setInput(controller); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.impact2585.frc2016.systems.WheelSystem#getInput() */ @Override @@ -123,7 +159,9 @@ public InputMethod getInput() { return super.getInput(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.impact2585.frc2016.systems.WheelSystem#drive(double, double) */ @Override @@ -132,23 +170,29 @@ public void drive(double movement, double currentRotate) { rotate = currentRotate; } - /* (non-Javadoc) - * @see org.impact2585.frc2016.systems.WheelSystem#setCurrentRampForward(double) + /* + * (non-Javadoc) + * + * @see + * org.impact2585.frc2016.systems.WheelSystem#setCurrentRampForward( + * double) */ @Override public void setCurrentRampForward(double rampForward) { super.setCurrentRampForward(rampForward); currentRampForward = rampForward; } - + } - + /** * input version for testing */ private class InputTest extends InputMethod { - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.impact2585.frc2016.input.InputMethod#forwardMovement() */ @Override @@ -156,7 +200,9 @@ public double forwardMovement() { return driveForward; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.impact2585.frc2016.input.InputMethod#getInvert() */ @Override @@ -164,14 +210,15 @@ public boolean invert() { return invert; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.impact2585.frc2016.input.InputMethod#rotationValue() */ @Override public double rotationValue() { return rotate; } - + } } -