Test bench fixes and updates. Attempting to make it possible to have a stable build again. Gyro test still seems a bit unreliable.

Change-Id: I0c140a5263048ff47ed1ec6b243e07baf43ec21e
This commit is contained in:
Patrick
2015-04-10 16:25:20 -04:00
committed by James Kuszmaul
parent 880eae1424
commit 675fbc032c
7 changed files with 82 additions and 75 deletions

View File

@@ -20,84 +20,86 @@ import edu.wpi.first.wpilibj.test.TestBench;
public class GyroTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(GyroTest.class.getName());
private static final Logger logger = Logger.getLogger(GyroTest.class.getName());
public static final double TEST_ANGLE = 90.0;
public static final double TEST_ANGLE = 90.0;
private TiltPanCameraFixture tpcam;
private TiltPanCameraFixture tpcam;
@Override
protected Logger getClassLogger() {
return logger;
}
@Override
protected Logger getClassLogger(){
return logger;
}
@Before
public void setUp() throws Exception {
logger.fine("Setup: TiltPan camera");
tpcam = TestBench.getInstance().getTiltPanCam();
tpcam.setup();
}
@Before
public void setUp() throws Exception {
logger.fine("Setup: TiltPan camera");
tpcam = TestBench.getInstance().getTiltPanCam();
tpcam.setup();
}
@After
public void tearDown() throws Exception {
tpcam.reset();
tpcam.teardown();
}
@After
public void tearDown() throws Exception {
tpcam.reset();
tpcam.teardown();
}
@Test
public void testInitial() {
double angle = tpcam.getGyro().getAngle();
assertEquals(errorMessage(angle, 0), 0, angle, .5);
}
@Test
public void testInitial(){
double angle = tpcam.getGyro().getAngle();
assertEquals(errorMessage(angle, 0), 0, angle, .5);
}
/**
* Test to see if the Servo and the gyroscope is turning 90 degrees Note
* servo on TestBench is not the same type of servo that servo class was
* designed for so setAngle is significantly off. This has been calibrated
* for the servo on the rig.
*/
@Test
public void testGyroAngle() {
//Set angle
for (int i = 0; i < 5; i++) {
tpcam.getPan().set(0);
Timer.delay(.1);
}
/**
* Test to see if the Servo and the gyroscope is turning 180 degrees
*/
@Test
public void testGyroAngle() {
//Set angle
for(int i = 0; i < 5; i++) {
tpcam.getPan().setAngle(45);
Timer.delay(.1);
}
Timer.delay(0.5);
//Reset for setup
tpcam.getGyro().reset();
Timer.delay(0.5);
Timer.delay(0.5);
//Reset for setup
tpcam.getGyro().reset();
Timer.delay(0.5);
//Perform test
for (int i = 0; i < 53; i++) {
tpcam.getPan().set(i / 100.0);
Timer.delay(0.05);
}
Timer.delay(1.2);
//Perform test
for(int i = 450; i < 1420; i++) {
tpcam.getPan().setAngle(i / 10.0);
Timer.delay(0.005);
}
Timer.delay(.2);
double angle = tpcam.getGyro().getAngle();
double angle = tpcam.getGyro().getAngle();
double difference = TEST_ANGLE - angle;
double difference = TEST_ANGLE - angle;
double diff = Math.abs(difference);
double diff = Math.abs(difference);
assertEquals(errorMessage(diff, TEST_ANGLE), TEST_ANGLE, angle, 10);
}
assertEquals(errorMessage(diff, TEST_ANGLE), TEST_ANGLE, angle, 4);
}
@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);
angle = tpcam.getGyro().getAngle();
assertEquals("After 5 seconds " + errorMessage(angle, 0), 0, angle, 1);
}
@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);
angle = tpcam.getGyro().getAngle();
assertEquals("After 5 seconds " + errorMessage(angle, 0), 0, angle, 1);
}
private String errorMessage(double difference, double target){
return "Gryo angle skewed " + difference + " deg away from target " + target;
}
private String errorMessage(double difference, double target) {
return "Gyro angle skewed " + difference + " deg away from target " + target;
}
}

View File

@@ -181,7 +181,7 @@ public class CANDefaultTest extends AbstractCANTest{
@Test
public void testPositionModeVerifiesOnBrownOut() {
final double setpoint = 10.0;
final double setpoint = 1.0;
//Given
getME().getMotor().setPositionMode(CANJaguar.kQuadEncoder, 360, 10.0, 0.1, 0.0);

View File

@@ -57,9 +57,9 @@ public class CANSpeedQuadEncoderModeTest extends AbstractCANTest {
*/
@Test
public void testRotateForwardSpeed() {
double speed = 60.0f;
double speed = 50.0f;
double initialPosition = getME().getMotor().getPosition();
setCANJaguar(kMotorTime, speed);
setCANJaguar(2*kMotorTime, speed);
assertEquals("The motor did not reach the required speed in speed mode", speed, getME().getMotor().getSpeed(), kEncoderSpeedTolerance);
assertThat("The motor did not move forward in speed mode", getME().getMotor().getPosition(), is(greaterThan(initialPosition)));
}
@@ -70,9 +70,9 @@ public class CANSpeedQuadEncoderModeTest extends AbstractCANTest {
*/
@Test
public void testRotateReverseSpeed() {
double speed = -60.0f;
double speed = -50.0f;
double initialPosition = getME().getMotor().getPosition();
setCANJaguar(kMotorTime, speed);
setCANJaguar(2*kMotorTime, speed);
assertEquals("The motor did not reach the required speed in speed mode", speed, getME().getMotor().getSpeed(), kEncoderSpeedTolerance);
assertThat("The motor did not move in reverse in speed mode", getME().getMotor().getPosition(), is(lessThan(initialPosition)));
}

View File

@@ -33,7 +33,7 @@ public class CANVoltageQuadEncoderModeTest extends AbstractCANTest {
/** The stopped value in volts */
private static final double kStoppedValue = 0;
/** The running value in volts */
private static final double kRunningValue = 12;
private static final double kRunningValue = 4;
private static final double kVoltageTolerance = .25;
@@ -110,7 +110,7 @@ public class CANVoltageQuadEncoderModeTest extends AbstractCANTest {
@Test
public void testMaxOutputVoltagePositive(){
//given
double maxVoltage = 5;
double maxVoltage = 3;
setupMotorVoltageForTest(kRunningValue, kWait);
@@ -155,7 +155,7 @@ public class CANVoltageQuadEncoderModeTest extends AbstractCANTest {
@Test
public void testMaxOutputVoltageNegative(){
//given
double maxVoltage = 5;
double maxVoltage = 3;
setupMotorVoltageForTest(-kRunningValue, kWait);
final double fastSpeed = getME().getMotor().getSpeed();