mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[wpilib] Add TimedRobot functions for running code on mode exit (#3499)
Currently, we have functions like TeleopInit() for running code on mode entry, but no such functions for running code on mode exit, and it's cumbersome to add those in user code without making a custom robot class. This PR adds exit functions to TimedRobot. Some example use cases include DisabledExit() for operations when the robot enables (whether that be into teleop, autonomous, or test) and AutonomousExit() for disabling feedback controllers.
This commit is contained in:
@@ -94,6 +94,14 @@ void IterativeRobotBase::TestPeriodic() {
|
||||
}
|
||||
}
|
||||
|
||||
void IterativeRobotBase::DisabledExit() {}
|
||||
|
||||
void IterativeRobotBase::AutonomousExit() {}
|
||||
|
||||
void IterativeRobotBase::TeleopExit() {}
|
||||
|
||||
void IterativeRobotBase::TestExit() {}
|
||||
|
||||
void IterativeRobotBase::SetNetworkTablesFlushEnabled(bool enabled) {
|
||||
m_ntFlushEnabled = enabled;
|
||||
}
|
||||
@@ -105,60 +113,67 @@ units::second_t IterativeRobotBase::GetPeriod() const {
|
||||
void IterativeRobotBase::LoopFunc() {
|
||||
m_watchdog.Reset();
|
||||
|
||||
// Call the appropriate function depending upon the current robot mode
|
||||
// Get current mode
|
||||
Mode mode = Mode::kNone;
|
||||
if (IsDisabled()) {
|
||||
// Call DisabledInit() if we are now just entering disabled mode from
|
||||
// either a different mode or from power-on.
|
||||
if (m_lastMode != Mode::kDisabled) {
|
||||
mode = Mode::kDisabled;
|
||||
} else if (IsAutonomous()) {
|
||||
mode = Mode::kAutonomous;
|
||||
} else if (IsOperatorControl()) {
|
||||
mode = Mode::kTeleop;
|
||||
} else if (IsTest()) {
|
||||
mode = Mode::kTest;
|
||||
}
|
||||
|
||||
// If mode changed, call mode exit and entry functions
|
||||
if (m_lastMode != mode) {
|
||||
// Call last mode's exit function
|
||||
if (m_lastMode == Mode::kDisabled) {
|
||||
DisabledExit();
|
||||
} else if (m_lastMode == Mode::kAutonomous) {
|
||||
AutonomousExit();
|
||||
} else if (m_lastMode == Mode::kTeleop) {
|
||||
TeleopExit();
|
||||
} else if (m_lastMode == Mode::kTest) {
|
||||
LiveWindow::SetEnabled(false);
|
||||
Shuffleboard::DisableActuatorWidgets();
|
||||
TestExit();
|
||||
}
|
||||
|
||||
// Call current mode's entry function
|
||||
if (mode == Mode::kDisabled) {
|
||||
DisabledInit();
|
||||
m_watchdog.AddEpoch("DisabledInit()");
|
||||
m_lastMode = Mode::kDisabled;
|
||||
}
|
||||
|
||||
HAL_ObserveUserProgramDisabled();
|
||||
DisabledPeriodic();
|
||||
m_watchdog.AddEpoch("DisabledPeriodic()");
|
||||
} else if (IsAutonomous()) {
|
||||
// Call AutonomousInit() if we are now just entering autonomous mode from
|
||||
// either a different mode or from power-on.
|
||||
if (m_lastMode != Mode::kAutonomous) {
|
||||
LiveWindow::SetEnabled(false);
|
||||
Shuffleboard::DisableActuatorWidgets();
|
||||
} else if (mode == Mode::kAutonomous) {
|
||||
AutonomousInit();
|
||||
m_watchdog.AddEpoch("AutonomousInit()");
|
||||
m_lastMode = Mode::kAutonomous;
|
||||
}
|
||||
|
||||
HAL_ObserveUserProgramAutonomous();
|
||||
AutonomousPeriodic();
|
||||
m_watchdog.AddEpoch("AutonomousPeriodic()");
|
||||
} else if (IsOperatorControl()) {
|
||||
// Call TeleopInit() if we are now just entering teleop mode from
|
||||
// either a different mode or from power-on.
|
||||
if (m_lastMode != Mode::kTeleop) {
|
||||
LiveWindow::SetEnabled(false);
|
||||
Shuffleboard::DisableActuatorWidgets();
|
||||
} else if (mode == Mode::kTeleop) {
|
||||
TeleopInit();
|
||||
m_watchdog.AddEpoch("TeleopInit()");
|
||||
m_lastMode = Mode::kTeleop;
|
||||
}
|
||||
|
||||
HAL_ObserveUserProgramTeleop();
|
||||
TeleopPeriodic();
|
||||
m_watchdog.AddEpoch("TeleopPeriodic()");
|
||||
} else {
|
||||
// Call TestInit() if we are now just entering test mode from
|
||||
// either a different mode or from power-on.
|
||||
if (m_lastMode != Mode::kTest) {
|
||||
} else if (mode == Mode::kTest) {
|
||||
LiveWindow::SetEnabled(true);
|
||||
Shuffleboard::EnableActuatorWidgets();
|
||||
TestInit();
|
||||
m_watchdog.AddEpoch("TestInit()");
|
||||
m_lastMode = Mode::kTest;
|
||||
}
|
||||
|
||||
m_lastMode = mode;
|
||||
}
|
||||
|
||||
// Call the appropriate function depending upon the current robot mode
|
||||
if (mode == Mode::kDisabled) {
|
||||
HAL_ObserveUserProgramDisabled();
|
||||
DisabledPeriodic();
|
||||
m_watchdog.AddEpoch("DisabledPeriodic()");
|
||||
} else if (mode == Mode::kAutonomous) {
|
||||
HAL_ObserveUserProgramAutonomous();
|
||||
AutonomousPeriodic();
|
||||
m_watchdog.AddEpoch("AutonomousPeriodic()");
|
||||
} else if (mode == Mode::kTeleop) {
|
||||
HAL_ObserveUserProgramTeleop();
|
||||
TeleopPeriodic();
|
||||
m_watchdog.AddEpoch("TeleopPeriodic()");
|
||||
} else if (mode == Mode::kTest) {
|
||||
HAL_ObserveUserProgramTest();
|
||||
TestPeriodic();
|
||||
m_watchdog.AddEpoch("TestPeriodic()");
|
||||
|
||||
@@ -25,22 +25,32 @@ namespace frc {
|
||||
* RobotInit() -- provide for initialization at robot power-on
|
||||
*
|
||||
* Init() functions -- each of the following functions is called once when the
|
||||
* appropriate mode is entered:
|
||||
* - DisabledInit() -- called each and every time disabled is entered from
|
||||
* another mode
|
||||
* - AutonomousInit() -- called each and every time autonomous is entered from
|
||||
* another mode
|
||||
* - TeleopInit() -- called each and every time teleop is entered from
|
||||
* another mode
|
||||
* - TestInit() -- called each and every time test is entered from
|
||||
* another mode
|
||||
* appropriate mode is entered:
|
||||
*
|
||||
* \li DisabledInit() -- called each and every time disabled is entered from
|
||||
* another mode
|
||||
* \li AutonomousInit() -- called each and every time autonomous is entered from
|
||||
* another mode
|
||||
* \li TeleopInit() -- called each and every time teleop is entered from another
|
||||
* mode
|
||||
* \li TestInit() -- called each and every time test is entered from another
|
||||
* mode
|
||||
*
|
||||
* Periodic() functions -- each of these functions is called on an interval:
|
||||
* - RobotPeriodic()
|
||||
* - DisabledPeriodic()
|
||||
* - AutonomousPeriodic()
|
||||
* - TeleopPeriodic()
|
||||
* - TestPeriodic()
|
||||
*
|
||||
* \li RobotPeriodic()
|
||||
* \li DisabledPeriodic()
|
||||
* \li AutonomousPeriodic()
|
||||
* \li TeleopPeriodic()
|
||||
* \li TestPeriodic()
|
||||
*
|
||||
* Exit() functions -- each of the following functions is called once when the
|
||||
* appropriate mode is exited:
|
||||
*
|
||||
* \li DisabledExit() -- called each and every time disabled is exited
|
||||
* \li AutonomousExit() -- called each and every time autonomous is exited
|
||||
* \li TeleopExit() -- called each and every time teleop is exited
|
||||
* \li TestExit() -- called each and every time test is exited
|
||||
*/
|
||||
class IterativeRobotBase : public RobotBase {
|
||||
public:
|
||||
@@ -152,6 +162,38 @@ class IterativeRobotBase : public RobotBase {
|
||||
*/
|
||||
virtual void TestPeriodic();
|
||||
|
||||
/**
|
||||
* Exit code for disabled mode should go here.
|
||||
*
|
||||
* Users should override this method for code which will be called each time
|
||||
* the robot exits disabled mode.
|
||||
*/
|
||||
virtual void DisabledExit();
|
||||
|
||||
/**
|
||||
* Exit code for autonomous mode should go here.
|
||||
*
|
||||
* Users should override this method for code which will be called each time
|
||||
* the robot exits autonomous mode.
|
||||
*/
|
||||
virtual void AutonomousExit();
|
||||
|
||||
/**
|
||||
* Exit code for teleop mode should go here.
|
||||
*
|
||||
* Users should override this method for code which will be called each time
|
||||
* the robot exits teleop mode.
|
||||
*/
|
||||
virtual void TeleopExit();
|
||||
|
||||
/**
|
||||
* Exit code for test mode should go here.
|
||||
*
|
||||
* Users should override this method for code which will be called each time
|
||||
* the robot exits test mode.
|
||||
*/
|
||||
virtual void TestExit();
|
||||
|
||||
/**
|
||||
* Enables or disables flushing NetworkTables every loop iteration.
|
||||
* By default, this is disabled.
|
||||
|
||||
@@ -32,6 +32,11 @@ class MockRobot : public TimedRobot {
|
||||
std::atomic<uint32_t> m_teleopInitCount{0};
|
||||
std::atomic<uint32_t> m_testInitCount{0};
|
||||
|
||||
std::atomic<uint32_t> m_disabledExitCount{0};
|
||||
std::atomic<uint32_t> m_autonomousExitCount{0};
|
||||
std::atomic<uint32_t> m_teleopExitCount{0};
|
||||
std::atomic<uint32_t> m_testExitCount{0};
|
||||
|
||||
std::atomic<uint32_t> m_robotPeriodicCount{0};
|
||||
std::atomic<uint32_t> m_simulationPeriodicCount{0};
|
||||
std::atomic<uint32_t> m_disabledPeriodicCount{0};
|
||||
@@ -62,6 +67,14 @@ class MockRobot : public TimedRobot {
|
||||
void TeleopPeriodic() override { m_teleopPeriodicCount++; }
|
||||
|
||||
void TestPeriodic() override { m_testPeriodicCount++; }
|
||||
|
||||
void DisabledExit() override { m_disabledExitCount++; }
|
||||
|
||||
void AutonomousExit() override { m_autonomousExitCount++; }
|
||||
|
||||
void TeleopExit() override { m_teleopExitCount++; }
|
||||
|
||||
void TestExit() override { m_testExitCount++; }
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -88,6 +101,11 @@ TEST_F(TimedRobotTest, Disabled) {
|
||||
EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
|
||||
EXPECT_EQ(0u, robot.m_testPeriodicCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_robotInitCount);
|
||||
@@ -104,6 +122,11 @@ TEST_F(TimedRobotTest, Disabled) {
|
||||
EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
|
||||
EXPECT_EQ(0u, robot.m_testPeriodicCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_robotInitCount);
|
||||
@@ -120,6 +143,11 @@ TEST_F(TimedRobotTest, Disabled) {
|
||||
EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
|
||||
EXPECT_EQ(0u, robot.m_testPeriodicCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
robot.EndCompetition();
|
||||
robotThread.join();
|
||||
}
|
||||
@@ -149,6 +177,11 @@ TEST_F(TimedRobotTest, Autonomous) {
|
||||
EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
|
||||
EXPECT_EQ(0u, robot.m_testPeriodicCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_robotInitCount);
|
||||
@@ -165,6 +198,11 @@ TEST_F(TimedRobotTest, Autonomous) {
|
||||
EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
|
||||
EXPECT_EQ(0u, robot.m_testPeriodicCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_robotInitCount);
|
||||
@@ -181,6 +219,11 @@ TEST_F(TimedRobotTest, Autonomous) {
|
||||
EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
|
||||
EXPECT_EQ(0u, robot.m_testPeriodicCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
robot.EndCompetition();
|
||||
robotThread.join();
|
||||
}
|
||||
@@ -210,6 +253,11 @@ TEST_F(TimedRobotTest, Teleop) {
|
||||
EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
|
||||
EXPECT_EQ(0u, robot.m_testPeriodicCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_robotInitCount);
|
||||
@@ -226,6 +274,11 @@ TEST_F(TimedRobotTest, Teleop) {
|
||||
EXPECT_EQ(1u, robot.m_teleopPeriodicCount);
|
||||
EXPECT_EQ(0u, robot.m_testPeriodicCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_robotInitCount);
|
||||
@@ -242,6 +295,11 @@ TEST_F(TimedRobotTest, Teleop) {
|
||||
EXPECT_EQ(2u, robot.m_teleopPeriodicCount);
|
||||
EXPECT_EQ(0u, robot.m_testPeriodicCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
robot.EndCompetition();
|
||||
robotThread.join();
|
||||
}
|
||||
@@ -271,6 +329,11 @@ TEST_F(TimedRobotTest, Test) {
|
||||
EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
|
||||
EXPECT_EQ(0u, robot.m_testPeriodicCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_robotInitCount);
|
||||
@@ -287,6 +350,11 @@ TEST_F(TimedRobotTest, Test) {
|
||||
EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
|
||||
EXPECT_EQ(1u, robot.m_testPeriodicCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_robotInitCount);
|
||||
@@ -303,6 +371,117 @@ TEST_F(TimedRobotTest, Test) {
|
||||
EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
|
||||
EXPECT_EQ(2u, robot.m_testPeriodicCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
robot.EndCompetition();
|
||||
robotThread.join();
|
||||
}
|
||||
|
||||
TEST_F(TimedRobotTest, ModeChange) {
|
||||
MockRobot robot;
|
||||
|
||||
std::thread robotThread{[&] { robot.StartCompetition(); }};
|
||||
|
||||
// Start in disabled
|
||||
frc::sim::DriverStationSim::SetEnabled(false);
|
||||
frc::sim::DriverStationSim::SetAutonomous(false);
|
||||
frc::sim::DriverStationSim::SetTest(false);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
frc::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousInitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopInitCount);
|
||||
EXPECT_EQ(0u, robot.m_testInitCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousInitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopInitCount);
|
||||
EXPECT_EQ(0u, robot.m_testInitCount);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
// Transition to autonomous
|
||||
frc::sim::DriverStationSim::SetEnabled(true);
|
||||
frc::sim::DriverStationSim::SetAutonomous(true);
|
||||
frc::sim::DriverStationSim::SetTest(false);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(1u, robot.m_autonomousInitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopInitCount);
|
||||
EXPECT_EQ(0u, robot.m_testInitCount);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
// Transition to teleop
|
||||
frc::sim::DriverStationSim::SetEnabled(true);
|
||||
frc::sim::DriverStationSim::SetAutonomous(false);
|
||||
frc::sim::DriverStationSim::SetTest(false);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(1u, robot.m_autonomousInitCount);
|
||||
EXPECT_EQ(1u, robot.m_teleopInitCount);
|
||||
EXPECT_EQ(0u, robot.m_testInitCount);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(1u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
// Transition to test
|
||||
frc::sim::DriverStationSim::SetEnabled(true);
|
||||
frc::sim::DriverStationSim::SetAutonomous(false);
|
||||
frc::sim::DriverStationSim::SetTest(true);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(1u, robot.m_autonomousInitCount);
|
||||
EXPECT_EQ(1u, robot.m_teleopInitCount);
|
||||
EXPECT_EQ(1u, robot.m_testInitCount);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(1u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(1u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
// Transition to disabled
|
||||
frc::sim::DriverStationSim::SetEnabled(false);
|
||||
frc::sim::DriverStationSim::SetAutonomous(false);
|
||||
frc::sim::DriverStationSim::SetTest(false);
|
||||
|
||||
frc::sim::StepTiming(20_ms);
|
||||
|
||||
EXPECT_EQ(2u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(1u, robot.m_autonomousInitCount);
|
||||
EXPECT_EQ(1u, robot.m_teleopInitCount);
|
||||
EXPECT_EQ(1u, robot.m_testInitCount);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledExitCount);
|
||||
EXPECT_EQ(1u, robot.m_autonomousExitCount);
|
||||
EXPECT_EQ(1u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(1u, robot.m_testExitCount);
|
||||
|
||||
robot.EndCompetition();
|
||||
robotThread.join();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user