Merge "Tuned some values in tests to account for hardware imperfections."

This commit is contained in:
Brad Miller (WPI)
2015-06-03 05:49:39 -07:00
committed by Gerrit Code Review
5 changed files with 28 additions and 28 deletions

View File

@@ -274,7 +274,7 @@ TEST_F(CANJaguarTest, SpeedModeWorks) {
m_jaguar->SetSpeedMode(CANJaguar::QuadEncoder, 360, 0.1f, 0.003f, 0.01f);
m_jaguar->EnableControl();
constexpr float speed = 100.0f;
constexpr float speed = 60.0f;
SetJaguar(kMotorTime, speed);
EXPECT_NEAR(speed, m_jaguar->GetSpeed(), kEncoderSpeedTolerance);

View File

@@ -11,7 +11,7 @@
static constexpr double kServoResetTime = 2.0;
static constexpr double kTestAngle = 180.0;
static constexpr double kTestAngle = 90.0;
static constexpr double kTiltSetpoint0 = 0.22;
static constexpr double kTiltSetpoint45 = 0.45;
@@ -45,7 +45,7 @@ protected:
m_pan = new Servo(TestBench::kCameraPanChannel);
m_spiAccel = new ADXL345_SPI(SPI::kOnboardCS0);
m_tilt->SetAngle(90.0f);
m_tilt->Set(kTiltSetpoint45);
m_pan->SetAngle(0.0f);
Wait(kServoResetTime);
@@ -78,8 +78,8 @@ TEST_F(TiltPanCameraTest, GyroAngle) {
Wait(0.25);
m_gyro->Reset();
for(int i = 0; i < 1800; i++) {
m_pan->SetAngle(i / 10.0);
for(int i = 0; i < 600; i++) {
m_pan->Set(i / 1000.0);
Wait(0.001);
}

View File

@@ -66,9 +66,9 @@ public class GyroTest extends AbstractComsSetup {
//Reset for setup
tpcam.getGyro().reset();
Timer.delay(0.5);
//Perform test
for(int i = 450; i < 1350; i++) {
for(int i = 450; i < 1420; i++) {
tpcam.getPan().setAngle(i / 10.0);
Timer.delay(0.005);
}

View File

@@ -28,7 +28,7 @@ public class CANPositionQuadEncoderModeTest extends AbstractCANTest {
protected Logger getClassLogger() {
return logger;
}
/* (non-Javadoc)
* @see edu.wpi.first.wpilibj.can.AbstractCANTest#runMotorForward()
@@ -46,16 +46,16 @@ public class CANPositionQuadEncoderModeTest extends AbstractCANTest {
double postion = getME().getMotor().getPosition();
getME().getMotor().set(postion - 100);
}
@Before
public void setUp() throws Exception {
getME().getMotor().setPositionMode(CANJaguar.kQuadEncoder, 360, 10.0f, 0.1f, 0.0f);
getME().getMotor().setPositionMode(CANJaguar.kQuadEncoder, 360, 10.0f, 0.01f, 0.0f);
getME().getMotor().enableControl(0);
/* The motor might still have momentum from the previous test. */
Timer.delay(kStartupTime);
}
@Ignore("The encoder initial position is not validated so is sometimes not set properly")
@Test
public void testSetEncoderInitialPositionWithEnable(){
@@ -73,15 +73,15 @@ public class CANPositionQuadEncoderModeTest extends AbstractCANTest {
//then
assertEquals(encoderValue, getME().getMotor().getPosition(), 40);
}
/**
* Test if we can set a position and reach that position with PID control on
* the Jaguar.
*/
@Test
public void testEncoderPositionPIDForward() {
double setpoint = getME().getMotor().getPosition() + 10.0f;
double setpoint = getME().getMotor().getPosition() + 1.0f;
/* It should get to the setpoint within 10 seconds */
getME().getMotor().set(setpoint);
@@ -89,15 +89,15 @@ public class CANPositionQuadEncoderModeTest extends AbstractCANTest {
assertEquals("CAN Jaguar should have reached setpoint with PID control", setpoint, getME().getMotor().getPosition(), kEncoderPositionTolerance);
}
/**
* Test if we can set a position and reach that position with PID control on
* the Jaguar.
*/
@Test
public void testEncoderPositionPIDReverse() {
double setpoint = getME().getMotor().getPosition() - 10.0f;
double setpoint = getME().getMotor().getPosition() - 1.0f;
/* It should get to the setpoint within 10 seconds */
getME().getMotor().set(setpoint);
@@ -106,5 +106,5 @@ public class CANPositionQuadEncoderModeTest extends AbstractCANTest {
assertEquals("CAN Jaguar should have reached setpoint with PID control", setpoint, getME().getMotor().getPosition(), kEncoderPositionTolerance);
}
}

View File

@@ -30,12 +30,12 @@ public class CANSpeedQuadEncoderModeTest extends AbstractCANTest {
private static final double kStoppedValue = 0;
/** The running value in rev/min */
private static final double kRunningValue = 200;
@Override
protected Logger getClassLogger() {
return logger;
}
@Before
public void setUp() throws Exception {
getME().getMotor().setSpeedMode(CANJaguar.kQuadEncoder, 360, 0.1f, 0.003f, 0.01f);
@@ -44,37 +44,37 @@ public class CANSpeedQuadEncoderModeTest extends AbstractCANTest {
/* The motor might still have momentum from the previous test. */
Timer.delay(kStartupTime);
}
@Test
public void testDefaultSpeed(){
assertEquals("CAN Jaguar did not start with an initial speed of zero", 0.0f, getME().getMotor().getSpeed(), 0.3f);
}
/**
* Test if we can drive the motor forward in Speed mode and get a
* position back
*/
@Test
public void testRotateForwardSpeed() {
double speed = 200.0f;
double speed = 60.0f;
double initialPosition = getME().getMotor().getPosition();
setCANJaguar(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)));
}
/**
* Test if we can drive the motor backwards in Speed mode and get a
* position back
*/
@Test
public void testRotateReverseSpeed() {
double speed = -200.0f;
double speed = -60.0f;
double initialPosition = getME().getMotor().getPosition();
setCANJaguar(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)));
}
}