Gyro deadband defaults to 0

The gyro class no longer attempts to set a default deadband, but it still
has an optional SetDeadband() method.

The gyro integration tests were modified and still pass consistently.

Change-Id: I08a97b00b98b49b0a3c63306fcc809857523af2b
This commit is contained in:
Thomas Clark
2014-08-05 09:46:02 -04:00
parent 60a3fd0698
commit 43c566bd86
7 changed files with 50 additions and 86 deletions

View File

@@ -19,19 +19,19 @@ import edu.wpi.first.wpilibj.test.AbstractComsSetup;
import edu.wpi.first.wpilibj.test.TestBench;
public class GyroTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(GyroTest.class.getName());
public static final double TEST_ANGLE = 180.0;
private TiltPanCameraFixture tpcam;
@Override
protected Logger getClassLogger(){
return logger;
}
@Before
public void setUp() throws Exception {
logger.fine("Setup: TiltPan camera");
@@ -44,7 +44,7 @@ public class GyroTest extends AbstractComsSetup {
tpcam.reset();
tpcam.teardown();
}
@Test
public void testInitial(){
double angle = tpcam.getGyro().getAngle();
@@ -56,22 +56,21 @@ public class GyroTest extends AbstractComsSetup {
*/
@Test
public void testGyroAngle() {
for(double i = 0; i < 1.0; i+=.005){
//System.out.println("i: " + i);
//System.out.println("Angle " + tpcam.getGyro().getAngle());
tpcam.getPan().set(i);
Timer.delay(.025);
for(int i = 0; i < 1800; i++) {
tpcam.getPan().setAngle(i / 10.0);
Timer.delay(0.001);
}
//Timer.delay(TiltPanCameraFixture.RESET_TIME);
double angle = tpcam.getGyro().getAngle();
double difference = TEST_ANGLE - angle;
double diff = Math.abs(difference);
assertEquals(errorMessage(diff, TEST_ANGLE), TEST_ANGLE, angle, 8);
}
@Test
public void testDeviationOverTime(){
double angle = tpcam.getGyro().getAngle();
@@ -80,7 +79,7 @@ public class GyroTest extends AbstractComsSetup {
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;
}

View File

@@ -15,7 +15,7 @@ import edu.wpi.first.wpilibj.Timer;
/**
* A class to represent the a physical Camera with two servos (tilt and pan) designed to test to see if the
* gyroscope is operating normally.
*
*
* @author Jonathan Leitschuh
*
*/
@@ -48,9 +48,10 @@ public abstract class TiltPanCameraFixture implements ITestFixture {
pan = givePan();
pan.set(0);
Timer.delay(RESET_TIME);
logger.fine("Initializing the gyro");
gyro = giveGyro();
gyro.reset();
wasSetup = true;
}
return wasSetup;
@@ -84,5 +85,5 @@ public abstract class TiltPanCameraFixture implements ITestFixture {
gyro = null;
return true;
}
}

View File

@@ -47,24 +47,24 @@ public final class TestBench {
* completely stopped
*/
public static final double MOTOR_STOP_TIME = 0.20;
public static final int kTalonChannel = 10;
public static final int kVictorChannel = 1;
public static final int kJaguarChannel = 2;
/*TiltPanCamera Channels */
public static final int kGyroChannel = 0;
public static final double kGyroSensitivity = 0.0134897058674;
public static final double kGyroSensitivity = 0.013;
public static final int kTiltServoChannel = 9;
public static final int kPanServoChannel = 8;
/* PowerDistributionPanel channels */
public static final int kJaguarPDPChannel = 6;
public static final int kVictorPDPChannel = 8;
public static final int kTalonPDPChannel = 11;
public static final int kCANJaguarPDPChannel = 5;
/* CAN ASSOICATED CHANNELS */
public static final int kCANRelayPowerCycler = 1;
public static final int kFakeJaguarPotentiometer = 1;
@@ -177,7 +177,7 @@ public final class TestBench {
};
return jagPair;
}
public class BaseCANMotorEncoderFixture extends CANMotorEncoderFixture{
@Override
protected CANJaguar giveSpeedController() {
@@ -210,7 +210,7 @@ public final class TestBench {
protected Relay givePoweCycleRelay() {
return new Relay(kCANRelayPowerCycler);
}
@Override
public int getPDPChannel() {
return kCANJaguarPDPChannel;
@@ -394,7 +394,7 @@ public final class TestBench {
}
return instance;
}
/**
* Provides access to the output stream for the test system. This should be used instead of System.out
* This is gives us a way to implement changes to where the output text of this test system is sent.
@@ -403,7 +403,7 @@ public final class TestBench {
public static PrintStream out(){
return System.out;
}
/**
* Provides access to the error stream for the test system. This should be used instead of System.err
* This is gives us a way to implement changes to where the output text of this test system is sent.