mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Merge "Tuned some values in tests to account for hardware imperfections."
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user