mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
Don't force public variables to use Hungarian notation (#8774)
People generally have expressed a dislike for the Hungarian notation used in member variables, especially in examples/templates, and our styleguide shouldn't be forced on downstream consumers, so this removes all Hungarian notation from the examples/templates. There are _some_ benefits to Hungarian for private member variables (like knowing what's a member vs. local in a PR review) so we'll keep private member variables the same for now, but public variables should no longer use Hungarian notation, since it looks much worse. A new PMD XPath rule has been added to accomplish this goal. Some other non-compliant variables were fixed for the new rule.
This commit is contained in:
@@ -25,12 +25,12 @@ import org.wpilib.util.Preferences;
|
||||
|
||||
@ResourceLock("timing")
|
||||
class ArmSimulationTest {
|
||||
private Robot m_robot;
|
||||
private Thread m_thread;
|
||||
private Robot robot;
|
||||
private Thread thread;
|
||||
|
||||
private PWMMotorControllerSim m_motorSim;
|
||||
private EncoderSim m_encoderSim;
|
||||
private JoystickSim m_joystickSim;
|
||||
private PWMMotorControllerSim motorSim;
|
||||
private EncoderSim encoderSim;
|
||||
private JoystickSim joystickSim;
|
||||
|
||||
@BeforeEach
|
||||
void startThread() {
|
||||
@@ -38,27 +38,27 @@ class ArmSimulationTest {
|
||||
SimHooks.pauseTiming();
|
||||
SimHooks.setProgramStarted(false);
|
||||
DriverStationSim.resetData();
|
||||
m_robot = new Robot();
|
||||
m_thread = new Thread(m_robot::startCompetition);
|
||||
m_encoderSim = EncoderSim.createForChannel(Constants.kEncoderAChannel);
|
||||
m_motorSim = new PWMMotorControllerSim(Constants.kMotorPort);
|
||||
m_joystickSim = new JoystickSim(Constants.kJoystickPort);
|
||||
robot = new Robot();
|
||||
thread = new Thread(robot::startCompetition);
|
||||
encoderSim = EncoderSim.createForChannel(Constants.kEncoderAChannel);
|
||||
motorSim = new PWMMotorControllerSim(Constants.kMotorPort);
|
||||
joystickSim = new JoystickSim(Constants.kJoystickPort);
|
||||
|
||||
m_thread.start();
|
||||
thread.start();
|
||||
SimHooks.waitForProgramStart();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void stopThread() {
|
||||
m_robot.endCompetition();
|
||||
robot.endCompetition();
|
||||
try {
|
||||
m_thread.interrupt();
|
||||
m_thread.join();
|
||||
thread.interrupt();
|
||||
thread.join();
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
m_robot.close();
|
||||
m_encoderSim.resetData();
|
||||
robot.close();
|
||||
encoderSim.resetData();
|
||||
Preferences.remove(Constants.kArmPKey);
|
||||
Preferences.remove(Constants.kArmPositionKey);
|
||||
Preferences.removeAll();
|
||||
@@ -80,7 +80,7 @@ class ArmSimulationTest {
|
||||
DriverStationSim.setEnabled(true);
|
||||
DriverStationSim.notifyNewData();
|
||||
|
||||
assertTrue(m_encoderSim.getInitialized());
|
||||
assertTrue(encoderSim.getInitialized());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -88,50 +88,50 @@ class ArmSimulationTest {
|
||||
SimHooks.stepTiming(3);
|
||||
|
||||
// Ensure arm is still at minimum angle.
|
||||
assertEquals(Constants.kMinAngleRads, m_encoderSim.getDistance(), 2.0);
|
||||
assertEquals(Constants.kMinAngleRads, encoderSim.getDistance(), 2.0);
|
||||
}
|
||||
|
||||
{
|
||||
// Press button to reach setpoint
|
||||
m_joystickSim.setTrigger(true);
|
||||
m_joystickSim.notifyNewData();
|
||||
joystickSim.setTrigger(true);
|
||||
joystickSim.notifyNewData();
|
||||
|
||||
// advance 75 timesteps
|
||||
SimHooks.stepTiming(1.5);
|
||||
|
||||
assertEquals(setpoint, Units.radiansToDegrees(m_encoderSim.getDistance()), 2.0);
|
||||
assertEquals(setpoint, Units.radiansToDegrees(encoderSim.getDistance()), 2.0);
|
||||
|
||||
// advance 25 timesteps to see setpoint is held.
|
||||
SimHooks.stepTiming(0.5);
|
||||
|
||||
assertEquals(setpoint, Units.radiansToDegrees(m_encoderSim.getDistance()), 2.0);
|
||||
assertEquals(setpoint, Units.radiansToDegrees(encoderSim.getDistance()), 2.0);
|
||||
}
|
||||
|
||||
{
|
||||
// Unpress the button to go back down
|
||||
m_joystickSim.setTrigger(false);
|
||||
m_joystickSim.notifyNewData();
|
||||
joystickSim.setTrigger(false);
|
||||
joystickSim.notifyNewData();
|
||||
|
||||
// advance 150 timesteps
|
||||
SimHooks.stepTiming(3.0);
|
||||
|
||||
assertEquals(Constants.kMinAngleRads, m_encoderSim.getDistance(), 2.0);
|
||||
assertEquals(Constants.kMinAngleRads, encoderSim.getDistance(), 2.0);
|
||||
}
|
||||
|
||||
{
|
||||
// Press button to go back up
|
||||
m_joystickSim.setTrigger(true);
|
||||
m_joystickSim.notifyNewData();
|
||||
joystickSim.setTrigger(true);
|
||||
joystickSim.notifyNewData();
|
||||
|
||||
// advance 75 timesteps
|
||||
SimHooks.stepTiming(1.5);
|
||||
|
||||
assertEquals(setpoint, Units.radiansToDegrees(m_encoderSim.getDistance()), 2.0);
|
||||
assertEquals(setpoint, Units.radiansToDegrees(encoderSim.getDistance()), 2.0);
|
||||
|
||||
// advance 25 timesteps to see setpoint is held.
|
||||
SimHooks.stepTiming(0.5);
|
||||
|
||||
assertEquals(setpoint, Units.radiansToDegrees(m_encoderSim.getDistance()), 2.0);
|
||||
assertEquals(setpoint, Units.radiansToDegrees(encoderSim.getDistance()), 2.0);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -142,8 +142,8 @@ class ArmSimulationTest {
|
||||
// advance 75 timesteps
|
||||
SimHooks.stepTiming(3.5);
|
||||
|
||||
assertEquals(0.0, m_motorSim.getThrottle(), 0.01);
|
||||
assertEquals(Constants.kMinAngleRads, m_encoderSim.getDistance(), 2.0);
|
||||
assertEquals(0.0, motorSim.getThrottle(), 0.01);
|
||||
assertEquals(Constants.kMinAngleRads, encoderSim.getDistance(), 2.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ import org.wpilib.simulation.SimHooks;
|
||||
|
||||
@ResourceLock("timing")
|
||||
class ElevatorSimulationTest {
|
||||
private Robot m_robot;
|
||||
private Thread m_thread;
|
||||
private Robot robot;
|
||||
private Thread thread;
|
||||
|
||||
private PWMMotorControllerSim m_motorSim;
|
||||
private EncoderSim m_encoderSim;
|
||||
private JoystickSim m_joystickSim;
|
||||
private PWMMotorControllerSim motorSim;
|
||||
private EncoderSim encoderSim;
|
||||
private JoystickSim joystickSim;
|
||||
|
||||
@BeforeEach
|
||||
void startThread() {
|
||||
@@ -35,27 +35,27 @@ class ElevatorSimulationTest {
|
||||
SimHooks.pauseTiming();
|
||||
SimHooks.setProgramStarted(false);
|
||||
DriverStationSim.resetData();
|
||||
m_robot = new Robot();
|
||||
m_thread = new Thread(m_robot::startCompetition);
|
||||
m_encoderSim = EncoderSim.createForChannel(Constants.kEncoderAChannel);
|
||||
m_motorSim = new PWMMotorControllerSim(Constants.kMotorPort);
|
||||
m_joystickSim = new JoystickSim(Constants.kJoystickPort);
|
||||
robot = new Robot();
|
||||
thread = new Thread(robot::startCompetition);
|
||||
encoderSim = EncoderSim.createForChannel(Constants.kEncoderAChannel);
|
||||
motorSim = new PWMMotorControllerSim(Constants.kMotorPort);
|
||||
joystickSim = new JoystickSim(Constants.kJoystickPort);
|
||||
|
||||
m_thread.start();
|
||||
thread.start();
|
||||
SimHooks.waitForProgramStart();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void stopThread() {
|
||||
m_robot.endCompetition();
|
||||
robot.endCompetition();
|
||||
try {
|
||||
m_thread.interrupt();
|
||||
m_thread.join();
|
||||
thread.interrupt();
|
||||
thread.join();
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
m_robot.close();
|
||||
m_encoderSim.resetData();
|
||||
robot.close();
|
||||
encoderSim.resetData();
|
||||
RoboRioSim.resetData();
|
||||
DriverStationSim.resetData();
|
||||
DriverStationSim.notifyNewData();
|
||||
@@ -69,7 +69,7 @@ class ElevatorSimulationTest {
|
||||
DriverStationSim.setEnabled(true);
|
||||
DriverStationSim.notifyNewData();
|
||||
|
||||
assertTrue(m_encoderSim.getInitialized());
|
||||
assertTrue(encoderSim.getInitialized());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -77,50 +77,50 @@ class ElevatorSimulationTest {
|
||||
SimHooks.stepTiming(1);
|
||||
|
||||
// Ensure elevator is still at 0.
|
||||
assertEquals(0.0, m_encoderSim.getDistance(), 0.05);
|
||||
assertEquals(0.0, encoderSim.getDistance(), 0.05);
|
||||
}
|
||||
|
||||
{
|
||||
// Press button to reach setpoint
|
||||
m_joystickSim.setTrigger(true);
|
||||
m_joystickSim.notifyNewData();
|
||||
joystickSim.setTrigger(true);
|
||||
joystickSim.notifyNewData();
|
||||
|
||||
// advance 75 timesteps
|
||||
SimHooks.stepTiming(1.5);
|
||||
|
||||
assertEquals(Constants.kSetpoint, m_encoderSim.getDistance(), 0.05);
|
||||
assertEquals(Constants.kSetpoint, encoderSim.getDistance(), 0.05);
|
||||
|
||||
// advance 25 timesteps to see setpoint is held.
|
||||
SimHooks.stepTiming(0.5);
|
||||
|
||||
assertEquals(Constants.kSetpoint, m_encoderSim.getDistance(), 0.05);
|
||||
assertEquals(Constants.kSetpoint, encoderSim.getDistance(), 0.05);
|
||||
}
|
||||
|
||||
{
|
||||
// Unpress the button to go back down
|
||||
m_joystickSim.setTrigger(false);
|
||||
m_joystickSim.notifyNewData();
|
||||
joystickSim.setTrigger(false);
|
||||
joystickSim.notifyNewData();
|
||||
|
||||
// advance 75 timesteps
|
||||
SimHooks.stepTiming(1.5);
|
||||
|
||||
assertEquals(0.0, m_encoderSim.getDistance(), 0.05);
|
||||
assertEquals(0.0, encoderSim.getDistance(), 0.05);
|
||||
}
|
||||
|
||||
{
|
||||
// Press button to go back up
|
||||
m_joystickSim.setTrigger(true);
|
||||
m_joystickSim.notifyNewData();
|
||||
joystickSim.setTrigger(true);
|
||||
joystickSim.notifyNewData();
|
||||
|
||||
// advance 75 timesteps
|
||||
SimHooks.stepTiming(1.5);
|
||||
|
||||
assertEquals(Constants.kSetpoint, m_encoderSim.getDistance(), 0.05);
|
||||
assertEquals(Constants.kSetpoint, encoderSim.getDistance(), 0.05);
|
||||
|
||||
// advance 25 timesteps to see setpoint is held.
|
||||
SimHooks.stepTiming(0.5);
|
||||
|
||||
assertEquals(Constants.kSetpoint, m_encoderSim.getDistance(), 0.05);
|
||||
assertEquals(Constants.kSetpoint, encoderSim.getDistance(), 0.05);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -131,8 +131,8 @@ class ElevatorSimulationTest {
|
||||
// advance 75 timesteps
|
||||
SimHooks.stepTiming(1.5);
|
||||
|
||||
assertEquals(0.0, m_motorSim.getThrottle(), 0.05);
|
||||
assertEquals(0.0, m_encoderSim.getDistance(), 0.05);
|
||||
assertEquals(0.0, motorSim.getThrottle(), 0.05);
|
||||
assertEquals(0.0, encoderSim.getDistance(), 0.05);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,18 +18,18 @@ import org.wpilib.simulation.PWMMotorControllerSim;
|
||||
|
||||
class IntakeTest {
|
||||
static final double DELTA = 1e-2; // acceptable deviation range
|
||||
Intake m_intake;
|
||||
PWMMotorControllerSim m_simMotor;
|
||||
DoubleSolenoidSim m_simPiston;
|
||||
Intake intake;
|
||||
PWMMotorControllerSim simMotor;
|
||||
DoubleSolenoidSim simPiston;
|
||||
|
||||
@BeforeEach // this method will run before each test
|
||||
void setup() {
|
||||
assert HAL.initialize(500, 0); // initialize the HAL, crash if failed
|
||||
m_intake = new Intake(); // create our intake
|
||||
m_simMotor =
|
||||
intake = new Intake(); // create our intake
|
||||
simMotor =
|
||||
new PWMMotorControllerSim(
|
||||
IntakeConstants.kMotorPort); // create our simulation PWM motor controller
|
||||
m_simPiston =
|
||||
simPiston =
|
||||
new DoubleSolenoidSim(
|
||||
PneumaticsModuleType.CTRE_PCM,
|
||||
IntakeConstants.kPistonFwdChannel,
|
||||
@@ -39,33 +39,33 @@ class IntakeTest {
|
||||
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
|
||||
@AfterEach // this method will run after each test
|
||||
void shutdown() throws Exception {
|
||||
m_intake.close(); // destroy our intake object
|
||||
intake.close(); // destroy our intake object
|
||||
}
|
||||
|
||||
@Test // marks this method as a test
|
||||
void doesntWorkWhenClosed() {
|
||||
m_intake.retract(); // close the intake
|
||||
m_intake.activate(0.5); // try to activate the motor
|
||||
intake.retract(); // close the intake
|
||||
intake.activate(0.5); // try to activate the motor
|
||||
assertEquals(
|
||||
0.0, m_simMotor.getThrottle(), DELTA); // make sure that the value set to the motor is 0
|
||||
0.0, simMotor.getThrottle(), DELTA); // make sure that the value set to the motor is 0
|
||||
}
|
||||
|
||||
@Test
|
||||
void worksWhenOpen() {
|
||||
m_intake.deploy();
|
||||
m_intake.activate(0.5);
|
||||
assertEquals(0.5, m_simMotor.getThrottle(), DELTA);
|
||||
intake.deploy();
|
||||
intake.activate(0.5);
|
||||
assertEquals(0.5, simMotor.getThrottle(), DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
void retractTest() {
|
||||
m_intake.retract();
|
||||
assertEquals(DoubleSolenoid.Value.REVERSE, m_simPiston.get());
|
||||
intake.retract();
|
||||
assertEquals(DoubleSolenoid.Value.REVERSE, simPiston.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
void deployTest() {
|
||||
m_intake.deploy();
|
||||
assertEquals(DoubleSolenoid.Value.FORWARD, m_simPiston.get());
|
||||
intake.deploy();
|
||||
assertEquals(DoubleSolenoid.Value.FORWARD, simPiston.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ import org.wpilib.simulation.SimHooks;
|
||||
|
||||
@ResourceLock("timing")
|
||||
class DigitalCommunicationTest {
|
||||
private Robot m_robot;
|
||||
private Thread m_thread;
|
||||
private final DIOSim m_allianceOutput = new DIOSim(Robot.kAlliancePort);
|
||||
private final DIOSim m_enabledOutput = new DIOSim(Robot.kEnabledPort);
|
||||
private final DIOSim m_autonomousOutput = new DIOSim(Robot.kAutonomousPort);
|
||||
private final DIOSim m_alertOutput = new DIOSim(Robot.kAlertPort);
|
||||
private Robot robot;
|
||||
private Thread thread;
|
||||
private final DIOSim allianceOutput = new DIOSim(Robot.kAlliancePort);
|
||||
private final DIOSim enabledOutput = new DIOSim(Robot.kEnabledPort);
|
||||
private final DIOSim autonomousOutput = new DIOSim(Robot.kAutonomousPort);
|
||||
private final DIOSim alertOutput = new DIOSim(Robot.kAlertPort);
|
||||
|
||||
@BeforeEach
|
||||
void startThread() {
|
||||
@@ -36,26 +36,26 @@ class DigitalCommunicationTest {
|
||||
SimHooks.pauseTiming();
|
||||
SimHooks.setProgramStarted(false);
|
||||
DriverStationSim.resetData();
|
||||
m_robot = new Robot();
|
||||
m_thread = new Thread(m_robot::startCompetition);
|
||||
m_thread.start();
|
||||
robot = new Robot();
|
||||
thread = new Thread(robot::startCompetition);
|
||||
thread.start();
|
||||
SimHooks.waitForProgramStart();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void stopThread() {
|
||||
m_robot.endCompetition();
|
||||
robot.endCompetition();
|
||||
try {
|
||||
m_thread.interrupt();
|
||||
m_thread.join();
|
||||
thread.interrupt();
|
||||
thread.join();
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
m_robot.close();
|
||||
m_allianceOutput.resetData();
|
||||
m_enabledOutput.resetData();
|
||||
m_autonomousOutput.resetData();
|
||||
m_alertOutput.resetData();
|
||||
robot.close();
|
||||
allianceOutput.resetData();
|
||||
enabledOutput.resetData();
|
||||
autonomousOutput.resetData();
|
||||
alertOutput.resetData();
|
||||
}
|
||||
|
||||
@EnumSource(AllianceStationID.class)
|
||||
@@ -64,12 +64,12 @@ class DigitalCommunicationTest {
|
||||
DriverStationSim.setAllianceStationId(alliance);
|
||||
DriverStationSim.notifyNewData();
|
||||
|
||||
assertTrue(m_allianceOutput.getInitialized());
|
||||
assertFalse(m_allianceOutput.getIsInput());
|
||||
assertTrue(allianceOutput.getInitialized());
|
||||
assertFalse(allianceOutput.getIsInput());
|
||||
|
||||
SimHooks.stepTiming(0.02);
|
||||
|
||||
assertEquals(alliance.name().startsWith("RED"), m_allianceOutput.getValue());
|
||||
assertEquals(alliance.name().startsWith("RED"), allianceOutput.getValue());
|
||||
}
|
||||
|
||||
@ValueSource(booleans = {true, false})
|
||||
@@ -78,12 +78,12 @@ class DigitalCommunicationTest {
|
||||
DriverStationSim.setEnabled(enabled);
|
||||
DriverStationSim.notifyNewData();
|
||||
|
||||
assertTrue(m_enabledOutput.getInitialized());
|
||||
assertFalse(m_enabledOutput.getIsInput());
|
||||
assertTrue(enabledOutput.getInitialized());
|
||||
assertFalse(enabledOutput.getIsInput());
|
||||
|
||||
SimHooks.stepTiming(0.02);
|
||||
|
||||
assertEquals(enabled, m_enabledOutput.getValue());
|
||||
assertEquals(enabled, enabledOutput.getValue());
|
||||
}
|
||||
|
||||
@ValueSource(booleans = {true, false})
|
||||
@@ -92,12 +92,12 @@ class DigitalCommunicationTest {
|
||||
DriverStationSim.setRobotMode(autonomous ? RobotMode.AUTONOMOUS : RobotMode.TELEOPERATED);
|
||||
DriverStationSim.notifyNewData();
|
||||
|
||||
assertTrue(m_autonomousOutput.getInitialized());
|
||||
assertFalse(m_autonomousOutput.getIsInput());
|
||||
assertTrue(autonomousOutput.getInitialized());
|
||||
assertFalse(autonomousOutput.getIsInput());
|
||||
|
||||
SimHooks.stepTiming(0.02);
|
||||
|
||||
assertEquals(autonomous, m_autonomousOutput.getValue());
|
||||
assertEquals(autonomous, autonomousOutput.getValue());
|
||||
}
|
||||
|
||||
@ValueSource(doubles = {45.0, 27.0, 23.0})
|
||||
@@ -106,11 +106,11 @@ class DigitalCommunicationTest {
|
||||
DriverStationSim.setMatchTime(matchTime);
|
||||
DriverStationSim.notifyNewData();
|
||||
|
||||
assertTrue(m_alertOutput.getInitialized());
|
||||
assertFalse(m_alertOutput.getIsInput());
|
||||
assertTrue(alertOutput.getInitialized());
|
||||
assertFalse(alertOutput.getIsInput());
|
||||
|
||||
SimHooks.stepTiming(0.02);
|
||||
|
||||
assertEquals(matchTime <= 30 && matchTime >= 25, m_alertOutput.getValue());
|
||||
assertEquals(matchTime <= 30 && matchTime >= 25, alertOutput.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ import org.wpilib.simulation.SimHooks;
|
||||
|
||||
@ResourceLock("timing")
|
||||
class I2CCommunicationTest {
|
||||
private Robot m_robot;
|
||||
private Thread m_thread;
|
||||
private final I2CSim m_i2c = new I2CSim(Robot.kPort.value);
|
||||
private CompletableFuture<String> m_future;
|
||||
private CallbackStore m_callback;
|
||||
private Robot robot;
|
||||
private Thread thread;
|
||||
private final I2CSim i2c = new I2CSim(Robot.kPort.value);
|
||||
private CompletableFuture<String> future;
|
||||
private CallbackStore callback;
|
||||
|
||||
@BeforeEach
|
||||
void startThread() {
|
||||
@@ -40,29 +40,29 @@ class I2CCommunicationTest {
|
||||
SimHooks.pauseTiming();
|
||||
SimHooks.setProgramStarted(false);
|
||||
DriverStationSim.resetData();
|
||||
m_future = new CompletableFuture<>();
|
||||
m_callback =
|
||||
m_i2c.registerWriteCallback(
|
||||
future = new CompletableFuture<>();
|
||||
callback =
|
||||
i2c.registerWriteCallback(
|
||||
(name, buffer, count) ->
|
||||
m_future.complete(new String(buffer, 0, count, StandardCharsets.UTF_8)));
|
||||
m_robot = new Robot();
|
||||
m_thread = new Thread(m_robot::startCompetition);
|
||||
m_thread.start();
|
||||
future.complete(new String(buffer, 0, count, StandardCharsets.UTF_8)));
|
||||
robot = new Robot();
|
||||
thread = new Thread(robot::startCompetition);
|
||||
thread.start();
|
||||
SimHooks.waitForProgramStart();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void stopThread() {
|
||||
m_robot.endCompetition();
|
||||
robot.endCompetition();
|
||||
try {
|
||||
m_thread.interrupt();
|
||||
m_thread.join();
|
||||
thread.interrupt();
|
||||
thread.join();
|
||||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
m_robot.close();
|
||||
m_callback.close();
|
||||
m_i2c.resetData();
|
||||
robot.close();
|
||||
callback.close();
|
||||
i2c.resetData();
|
||||
}
|
||||
|
||||
@EnumSource(AllianceStationID.class)
|
||||
@@ -71,11 +71,11 @@ class I2CCommunicationTest {
|
||||
DriverStationSim.setAllianceStationId(alliance);
|
||||
DriverStationSim.notifyNewData();
|
||||
|
||||
assertTrue(m_i2c.getInitialized());
|
||||
assertTrue(i2c.getInitialized());
|
||||
|
||||
SimHooks.stepTiming(0.02);
|
||||
|
||||
String str = assertTimeoutPreemptively(Duration.ofMillis(20L), () -> m_future.get());
|
||||
String str = assertTimeoutPreemptively(Duration.ofMillis(20L), () -> future.get());
|
||||
char expected = alliance.name().startsWith("RED") ? 'R' : 'B';
|
||||
if (alliance.name().startsWith("UNKNOWN")) {
|
||||
expected = 'U';
|
||||
@@ -90,11 +90,11 @@ class I2CCommunicationTest {
|
||||
DriverStationSim.setEnabled(enabled);
|
||||
DriverStationSim.notifyNewData();
|
||||
|
||||
assertTrue(m_i2c.getInitialized());
|
||||
assertTrue(i2c.getInitialized());
|
||||
|
||||
SimHooks.stepTiming(0.02);
|
||||
|
||||
String str = assertTimeoutPreemptively(Duration.ofMillis(20L), () -> m_future.get());
|
||||
String str = assertTimeoutPreemptively(Duration.ofMillis(20L), () -> future.get());
|
||||
char expected = enabled ? 'E' : 'D';
|
||||
|
||||
assertEquals(expected, str.charAt(1));
|
||||
@@ -106,11 +106,11 @@ class I2CCommunicationTest {
|
||||
DriverStationSim.setRobotMode(autonomous ? RobotMode.AUTONOMOUS : RobotMode.TELEOPERATED);
|
||||
DriverStationSim.notifyNewData();
|
||||
|
||||
assertTrue(m_i2c.getInitialized());
|
||||
assertTrue(i2c.getInitialized());
|
||||
|
||||
SimHooks.stepTiming(0.02);
|
||||
|
||||
String str = assertTimeoutPreemptively(Duration.ofMillis(20L), () -> m_future.get());
|
||||
String str = assertTimeoutPreemptively(Duration.ofMillis(20L), () -> future.get());
|
||||
char expected = autonomous ? 'A' : 'T';
|
||||
|
||||
assertEquals(expected, str.charAt(2));
|
||||
@@ -121,11 +121,11 @@ class I2CCommunicationTest {
|
||||
void matchTimeTest(double matchTime) {
|
||||
DriverStationSim.setMatchTime(matchTime);
|
||||
DriverStationSim.notifyNewData();
|
||||
assertTrue(m_i2c.getInitialized());
|
||||
assertTrue(i2c.getInitialized());
|
||||
|
||||
SimHooks.stepTiming(0.02);
|
||||
|
||||
String str = assertTimeoutPreemptively(Duration.ofMillis(20L), () -> m_future.get());
|
||||
String str = assertTimeoutPreemptively(Duration.ofMillis(20L), () -> future.get());
|
||||
String expected = String.format("%03d", (int) MatchState.getMatchTime());
|
||||
|
||||
assertEquals(expected, str.substring(3));
|
||||
|
||||
Reference in New Issue
Block a user