[hal,wpilib] Rename "Test" robot mode to "Utility" (#8782)

The "Utility" name better matches its intended generic use case and
avoids overloaded terminology with unit testing (e.g. the need to name
the opmode annotation `@TestOpMode`).

The driver station will also be updated to reflect this change.
This commit is contained in:
Peter Johnson
2026-04-20 20:29:25 -07:00
committed by GitHub
parent 14d14e4ebc
commit ab00aac960
111 changed files with 487 additions and 488 deletions

View File

@@ -12,7 +12,7 @@ Robot::Robot() {}
/**
* This function is called every 20 ms, no matter the mode. Use
* this for items like diagnostics that you want to run during disabled,
* autonomous, teleoperated and test.
* autonomous, teleoperated and utility.
*
* <p> This runs after the mode specific periodic functions, but before
* LiveWindow and SmartDashboard integrated updating.
@@ -62,9 +62,9 @@ void Robot::TeleopInit() {
void Robot::TeleopPeriodic() {}
/**
* This function is called periodically during test mode.
* This function is called periodically during utility mode.
*/
void Robot::TestPeriodic() {}
void Robot::UtilityPeriodic() {}
#ifndef RUNNING_WPILIB_TESTS
int main() {

View File

@@ -20,7 +20,7 @@ class Robot : public wpi::TimedRobot {
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
void UtilityPeriodic() override;
private:
// Have it null by default so that if testing teleop it

View File

@@ -43,9 +43,9 @@ class Robot : public wpi::TimedRobot {
m_controller.GetRightX());
}
void TestInit() override {}
void UtilityInit() override {}
void TestPeriodic() override {}
void UtilityPeriodic() override {}
private:
// Robot drive system

View File

@@ -56,8 +56,8 @@ int main(void) {
{"", 0},
-1,
-1},
{HAL_MAKE_OPMODEID(HAL_ROBOT_MODE_TEST, 0),
{"Test", 4},
{HAL_MAKE_OPMODEID(HAL_ROBOT_MODE_UTILITY, 0),
{"Utility", 4},
{"", 0},
{"", 0},
-1,
@@ -116,7 +116,7 @@ int main(void) {
break;
case HAL_ROBOT_MODE_AUTONOMOUS:
break;
case HAL_ROBOT_MODE_TEST:
case HAL_ROBOT_MODE_UTILITY:
break;
default:
break;

View File

@@ -21,7 +21,7 @@ Robot::Robot() {
/**
* This function is called every 20 ms, no matter the mode. Use
* this for items like diagnostics that you want to run during disabled,
* autonomous, teleoperated and test.
* autonomous, teleoperated and utility.
*
* <p> This runs after the mode specific periodic functions, but before
* LiveWindow and SmartDashboard integrated updating.
@@ -70,9 +70,9 @@ void Robot::TeleopInit() {
void Robot::TeleopPeriodic() {}
/**
* This function is called periodically during test mode.
* This function is called periodically during utility mode.
*/
void Robot::TestPeriodic() {}
void Robot::UtilityPeriodic() {}
#ifndef RUNNING_WPILIB_TESTS
int main() {

View File

@@ -18,7 +18,7 @@ class Robot : public wpi::TimedRobot {
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
void UtilityPeriodic() override;
private:
// Have it null by default so that if testing teleop it

View File

@@ -21,7 +21,7 @@ Robot::Robot() {
/**
* This function is called every 20 ms, no matter the mode. Use
* this for items like diagnostics that you want to run during disabled,
* autonomous, teleoperated and test.
* autonomous, teleoperated and utility.
*
* <p> This runs after the mode specific periodic functions, but before
* LiveWindow and SmartDashboard integrated updating.
@@ -70,9 +70,9 @@ void Robot::TeleopInit() {
void Robot::TeleopPeriodic() {}
/**
* This function is called periodically during test mode.
* This function is called periodically during utility mode.
*/
void Robot::TestPeriodic() {}
void Robot::UtilityPeriodic() {}
#ifndef RUNNING_WPILIB_TESTS
int main() {

View File

@@ -18,7 +18,7 @@ class Robot : public wpi::TimedRobot {
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
void UtilityPeriodic() override;
private:
// Have it null by default so that if testing teleop it

View File

@@ -45,12 +45,12 @@ void Robot::TeleopInit() {
void Robot::TeleopPeriodic() {}
void Robot::TestInit() {
// Cancels all running commands at the start of test mode.
void Robot::UtilityInit() {
// Cancels all running commands at the start of utility mode.
wpi::cmd::CommandScheduler::GetInstance().CancelAll();
}
void Robot::TestPeriodic() {}
void Robot::UtilityPeriodic() {}
#ifndef RUNNING_WPILIB_TESTS
int main() {

View File

@@ -20,8 +20,8 @@ class Robot : public wpi::TimedRobot {
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestInit() override;
void TestPeriodic() override;
void UtilityInit() override;
void UtilityPeriodic() override;
private:
RapidReactCommandBot m_robot;

View File

@@ -11,7 +11,7 @@ Robot::Robot() {}
/**
* This function is called every 20 ms, no matter the mode. Use
* this for items like diagnostics that you want to run during disabled,
* autonomous, teleoperated and test.
* autonomous, teleoperated and utility.
*
* <p> This runs after the mode specific periodic functions, but before
* LiveWindow and SmartDashboard integrated updating.
@@ -60,9 +60,9 @@ void Robot::TeleopInit() {
void Robot::TeleopPeriodic() {}
/**
* This function is called periodically during test mode.
* This function is called periodically during utility mode.
*/
void Robot::TestPeriodic() {}
void Robot::UtilityPeriodic() {}
#ifndef RUNNING_WPILIB_TESTS
int main() {

View File

@@ -18,7 +18,7 @@ class Robot : public wpi::TimedRobot {
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
void UtilityPeriodic() override;
private:
// Have it null by default so that if testing teleop it

View File

@@ -41,13 +41,13 @@ void Robot::TeleopPeriodic() {}
void Robot::TeleopExit() {}
void Robot::TestInit() {
void Robot::UtilityInit() {
wpi::cmd::CommandScheduler::GetInstance().CancelAll();
}
void Robot::TestPeriodic() {}
void Robot::UtilityPeriodic() {}
void Robot::TestExit() {}
void Robot::UtilityExit() {}
#ifndef RUNNING_WPILIB_TESTS
int main() {

View File

@@ -23,9 +23,9 @@ class Robot : public wpi::TimedRobot {
void TeleopInit() override;
void TeleopPeriodic() override;
void TeleopExit() override;
void TestInit() override;
void TestPeriodic() override;
void TestExit() override;
void UtilityInit() override;
void UtilityPeriodic() override;
void UtilityExit() override;
private:
std::optional<wpi::cmd::CommandPtr> m_autonomousCommand;

View File

@@ -11,7 +11,7 @@ Robot::Robot() {}
/**
* This function is called every 20 ms, no matter the mode. Use
* this for items like diagnostics that you want to run during disabled,
* autonomous, teleoperated and test.
* autonomous, teleoperated and utility.
*
* <p> This runs after the mode specific periodic functions, but before
* LiveWindow and SmartDashboard integrated updating.
@@ -60,9 +60,9 @@ void Robot::TeleopInit() {
void Robot::TeleopPeriodic() {}
/**
* This function is called periodically during test mode.
* This function is called periodically during utility mode.
*/
void Robot::TestPeriodic() {}
void Robot::UtilityPeriodic() {}
#ifndef RUNNING_WPILIB_TESTS
int main() {

View File

@@ -18,7 +18,7 @@ class Robot : public wpi::TimedRobot {
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
void UtilityPeriodic() override;
private:
// Have it null by default so that if testing teleop it

View File

@@ -17,7 +17,7 @@ Robot::Robot() {
/**
* This function is called every 20 ms, no matter the mode. Use
* this for items like diagnostics that you want ran during disabled,
* autonomous, teleoperated and test.
* autonomous, teleoperated and utility.
*
* <p> This runs after the mode specific periodic functions, but before
* LiveWindow and SmartDashboard integrated updating.

View File

@@ -61,9 +61,9 @@ void Robot::TeleopInit() {
void Robot::TeleopPeriodic() {}
/**
* This function is called periodically during test mode.
* This function is called periodically during utility mode.
*/
void Robot::TestPeriodic() {}
void Robot::UtilityPeriodic() {}
#ifndef RUNNING_WPILIB_TESTS
int main() {

View File

@@ -18,7 +18,7 @@ class Robot : public wpi::TimedRobot {
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
void UtilityPeriodic() override;
private:
// Have it null by default so that if testing teleop it

View File

@@ -11,7 +11,7 @@ Robot::Robot() {}
/**
* This function is called every 20 ms, no matter the mode. Use
* this for items like diagnostics that you want to run during disabled,
* autonomous, teleoperated and test.
* autonomous, teleoperated and utility.
*
* <p> This runs after the mode specific periodic functions, but before
* LiveWindow and SmartDashboard integrated updating.
@@ -60,9 +60,9 @@ void Robot::TeleopInit() {
void Robot::TeleopPeriodic() {}
/**
* This function is called periodically during test mode.
* This function is called periodically during utility mode.
*/
void Robot::TestPeriodic() {}
void Robot::UtilityPeriodic() {}
/**
* This function is called once when the robot is first started up.

View File

@@ -20,7 +20,7 @@ class Robot : public wpi::TimedRobot {
void AutonomousPeriodic() override;
void TeleopInit() override;
void TeleopPeriodic() override;
void TestPeriodic() override;
void UtilityPeriodic() override;
void SimulationInit() override;
void SimulationPeriodic() override;

View File

@@ -41,13 +41,13 @@ void Robot::TeleopPeriodic() {}
void Robot::TeleopExit() {}
void Robot::TestInit() {
void Robot::UtilityInit() {
wpi::cmd::CommandScheduler::GetInstance().CancelAll();
}
void Robot::TestPeriodic() {}
void Robot::UtilityPeriodic() {}
void Robot::TestExit() {}
void Robot::UtilityExit() {}
#ifndef RUNNING_WPILIB_TESTS
int main() {

View File

@@ -23,9 +23,9 @@ class Robot : public wpi::TimedRobot {
void TeleopInit() override;
void TeleopPeriodic() override;
void TeleopExit() override;
void TestInit() override;
void TestPeriodic() override;
void TestExit() override;
void UtilityInit() override;
void UtilityPeriodic() override;
void UtilityExit() override;
private:
std::optional<wpi::cmd::CommandPtr> m_autonomousCommand;

View File

@@ -17,7 +17,7 @@ void Robot::Autonomous() {}
void Robot::Teleop() {}
void Robot::Test() {}
void Robot::Utility() {}
void Robot::StartCompetition() {
wpi::internal::DriverStationModeThread modeThread{wpi::hal::GetControlWord()};
@@ -25,7 +25,7 @@ void Robot::StartCompetition() {
// Create an opmode per robot mode
wpi::RobotState::AddOpMode(wpi::RobotMode::AUTONOMOUS, "Auto");
wpi::RobotState::AddOpMode(wpi::RobotMode::TELEOPERATED, "Teleop");
wpi::RobotState::AddOpMode(wpi::RobotMode::TEST, "Test");
wpi::RobotState::AddOpMode(wpi::RobotMode::UTILITY, "Utility");
wpi::RobotState::PublishOpModes();
wpi::util::Event event{false, false};
@@ -47,9 +47,9 @@ void Robot::StartCompetition() {
while (IsAutonomousEnabled()) {
wpi::util::WaitForObject(event.GetHandle());
}
} else if (IsTest()) {
Test();
while (IsTest() && IsEnabled()) {
} else if (IsUtility()) {
Utility();
while (IsUtility() && IsEnabled()) {
wpi::util::WaitForObject(event.GetHandle());
}
} else {

View File

@@ -14,7 +14,7 @@ class Robot : public wpi::RobotBase {
void Disabled();
void Autonomous();
void Teleop();
void Test();
void Utility();
void StartCompetition() override;
void EndCompetition() override;

View File

@@ -16,7 +16,7 @@ Robot::Robot() {
/**
* This function is called every 20 ms, no matter the mode. Use
* this for items like diagnostics that you want ran during disabled,
* autonomous, teleoperated and test.
* autonomous, teleoperated and utility.
*
* <p> This runs after the mode specific periodic functions, but before
* LiveWindow and SmartDashboard integrated updating.
@@ -63,9 +63,9 @@ void Robot::DisabledInit() {}
void Robot::DisabledPeriodic() {}
void Robot::TestInit() {}
void Robot::UtilityInit() {}
void Robot::TestPeriodic() {}
void Robot::UtilityPeriodic() {}
void Robot::SimulationInit() {}

View File

@@ -19,8 +19,8 @@ class Robot : public wpi::TimedRobot {
void TeleopPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
void TestInit() override;
void TestPeriodic() override;
void UtilityInit() override;
void UtilityPeriodic() override;
void SimulationInit() override;
void SimulationPeriodic() override;

View File

@@ -16,8 +16,8 @@ void Robot::TeleopPeriodic() {}
void Robot::DisabledInit() {}
void Robot::DisabledPeriodic() {}
void Robot::TestInit() {}
void Robot::TestPeriodic() {}
void Robot::UtilityInit() {}
void Robot::UtilityPeriodic() {}
void Robot::SimulationInit() {}
void Robot::SimulationPeriodic() {}

View File

@@ -20,8 +20,8 @@ class Robot : public wpi::TimedRobot {
void DisabledInit() override;
void DisabledPeriodic() override;
void TestInit() override;
void TestPeriodic() override;
void UtilityInit() override;
void UtilityPeriodic() override;
void SimulationInit() override;
void SimulationPeriodic() override;

View File

@@ -74,9 +74,9 @@ void Robot::DisabledInit() {}
void Robot::DisabledPeriodic() {}
void Robot::TestInit() {}
void Robot::UtilityInit() {}
void Robot::TestPeriodic() {}
void Robot::UtilityPeriodic() {}
#ifndef RUNNING_WPILIB_TESTS
int main() {

View File

@@ -19,8 +19,8 @@ class Robot : public wpi::TimesliceRobot {
void TeleopPeriodic() override;
void DisabledInit() override;
void DisabledPeriodic() override;
void TestInit() override;
void TestPeriodic() override;
void UtilityInit() override;
void UtilityPeriodic() override;
private:
wpi::SendableChooser<std::string> m_chooser;

View File

@@ -28,8 +28,8 @@ void Robot::TeleopPeriodic() {}
void Robot::DisabledInit() {}
void Robot::DisabledPeriodic() {}
void Robot::TestInit() {}
void Robot::TestPeriodic() {}
void Robot::UtilityInit() {}
void Robot::UtilityPeriodic() {}
#ifndef RUNNING_WPILIB_TESTS
int main() {

View File

@@ -21,6 +21,6 @@ class Robot : public wpi::TimesliceRobot {
void DisabledInit() override;
void DisabledPeriodic() override;
void TestInit() override;
void TestPeriodic() override;
void UtilityInit() override;
void UtilityPeriodic() override;
};