mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-06 03:31:43 +00:00
@@ -19,8 +19,6 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
* <p>This class provides the following functions which are called by the main loop,
|
||||
* startCompetition(), at the appropriate times:
|
||||
*
|
||||
* <p>robotInit() -- provide for initialization at robot power-on
|
||||
*
|
||||
* <p>driverStationConnected() -- provide for initialization the first time the DS is connected
|
||||
*
|
||||
* <p>init() functions -- each of the following functions is called once when the appropriate mode
|
||||
@@ -85,17 +83,6 @@ public abstract class IterativeRobotBase extends RobotBase {
|
||||
|
||||
/* ----------- Overridable initialization code ----------------- */
|
||||
|
||||
/**
|
||||
* Robot-wide initialization code should go here.
|
||||
*
|
||||
* <p>Users should override this method for default Robot-wide initialization which will be called
|
||||
* when the robot is first powered on. It will be called exactly one time.
|
||||
*
|
||||
* <p>Note: This method is functionally identical to the class constructor so that should be used
|
||||
* instead.
|
||||
*/
|
||||
public void robotInit() {}
|
||||
|
||||
/**
|
||||
* Code that needs to know the DS state should go here.
|
||||
*
|
||||
@@ -109,7 +96,7 @@ public abstract class IterativeRobotBase extends RobotBase {
|
||||
*
|
||||
* <p>Users should override this method for default Robot-wide simulation related initialization
|
||||
* which will be called when the robot is first started. It will be called exactly one time after
|
||||
* RobotInit is called only when the robot is in simulation.
|
||||
* the robot class constructor is called only when the robot is in simulation.
|
||||
*/
|
||||
public void simulationInit() {}
|
||||
|
||||
|
||||
@@ -102,8 +102,6 @@ public class TimedRobot extends IterativeRobotBase {
|
||||
/** Provide an alternate "main loop" via startCompetition(). */
|
||||
@Override
|
||||
public void startCompetition() {
|
||||
robotInit();
|
||||
|
||||
if (isSimulation()) {
|
||||
simulationInit();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ class TimedRobotTest {
|
||||
static final double kPeriod = 0.02;
|
||||
|
||||
static class MockRobot extends TimedRobot {
|
||||
public final AtomicInteger m_robotInitCount = new AtomicInteger(0);
|
||||
public final AtomicInteger m_simulationInitCount = new AtomicInteger(0);
|
||||
public final AtomicInteger m_disabledInitCount = new AtomicInteger(0);
|
||||
public final AtomicInteger m_autonomousInitCount = new AtomicInteger(0);
|
||||
@@ -39,8 +38,6 @@ class TimedRobotTest {
|
||||
|
||||
MockRobot() {
|
||||
super(kPeriod);
|
||||
|
||||
m_robotInitCount.addAndGet(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,7 +139,6 @@ class TimedRobotTest {
|
||||
DriverStationSim.notifyNewData();
|
||||
SimHooks.stepTiming(0.0); // Wait for Notifiers
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(0, robot.m_disabledInitCount.get());
|
||||
assertEquals(0, robot.m_autonomousInitCount.get());
|
||||
@@ -163,7 +159,6 @@ class TimedRobotTest {
|
||||
|
||||
SimHooks.stepTiming(kPeriod);
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(1, robot.m_disabledInitCount.get());
|
||||
assertEquals(0, robot.m_autonomousInitCount.get());
|
||||
@@ -184,7 +179,6 @@ class TimedRobotTest {
|
||||
|
||||
SimHooks.stepTiming(kPeriod);
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(1, robot.m_disabledInitCount.get());
|
||||
assertEquals(0, robot.m_autonomousInitCount.get());
|
||||
@@ -227,7 +221,6 @@ class TimedRobotTest {
|
||||
DriverStationSim.notifyNewData();
|
||||
SimHooks.stepTiming(0.0); // Wait for Notifiers
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(0, robot.m_disabledInitCount.get());
|
||||
assertEquals(0, robot.m_autonomousInitCount.get());
|
||||
@@ -248,7 +241,6 @@ class TimedRobotTest {
|
||||
|
||||
SimHooks.stepTiming(kPeriod);
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(0, robot.m_disabledInitCount.get());
|
||||
assertEquals(1, robot.m_autonomousInitCount.get());
|
||||
@@ -269,7 +261,6 @@ class TimedRobotTest {
|
||||
|
||||
SimHooks.stepTiming(kPeriod);
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(0, robot.m_disabledInitCount.get());
|
||||
assertEquals(1, robot.m_autonomousInitCount.get());
|
||||
@@ -312,7 +303,6 @@ class TimedRobotTest {
|
||||
DriverStationSim.notifyNewData();
|
||||
SimHooks.stepTiming(0.0); // Wait for Notifiers
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(0, robot.m_disabledInitCount.get());
|
||||
assertEquals(0, robot.m_autonomousInitCount.get());
|
||||
@@ -333,7 +323,6 @@ class TimedRobotTest {
|
||||
|
||||
SimHooks.stepTiming(kPeriod);
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(0, robot.m_disabledInitCount.get());
|
||||
assertEquals(0, robot.m_autonomousInitCount.get());
|
||||
@@ -354,7 +343,6 @@ class TimedRobotTest {
|
||||
|
||||
SimHooks.stepTiming(kPeriod);
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(0, robot.m_disabledInitCount.get());
|
||||
assertEquals(0, robot.m_autonomousInitCount.get());
|
||||
@@ -397,7 +385,6 @@ class TimedRobotTest {
|
||||
DriverStationSim.notifyNewData();
|
||||
SimHooks.stepTiming(0.0); // Wait for Notifiers
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(0, robot.m_disabledInitCount.get());
|
||||
assertEquals(0, robot.m_autonomousInitCount.get());
|
||||
@@ -418,7 +405,6 @@ class TimedRobotTest {
|
||||
|
||||
SimHooks.stepTiming(kPeriod);
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(0, robot.m_disabledInitCount.get());
|
||||
assertEquals(0, robot.m_autonomousInitCount.get());
|
||||
@@ -439,7 +425,6 @@ class TimedRobotTest {
|
||||
|
||||
SimHooks.stepTiming(kPeriod);
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(0, robot.m_disabledInitCount.get());
|
||||
assertEquals(0, robot.m_autonomousInitCount.get());
|
||||
@@ -465,7 +450,6 @@ class TimedRobotTest {
|
||||
|
||||
SimHooks.stepTiming(0.02);
|
||||
|
||||
assertEquals(1, robot.m_robotInitCount.get());
|
||||
assertEquals(1, robot.m_simulationInitCount.get());
|
||||
assertEquals(1, robot.m_disabledInitCount.get());
|
||||
assertEquals(0, robot.m_autonomousInitCount.get());
|
||||
|
||||
Reference in New Issue
Block a user