mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
[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:
@@ -29,7 +29,7 @@ void IterativeRobotBase::AutonomousInit() {}
|
||||
|
||||
void IterativeRobotBase::TeleopInit() {}
|
||||
|
||||
void IterativeRobotBase::TestInit() {}
|
||||
void IterativeRobotBase::UtilityInit() {}
|
||||
|
||||
void IterativeRobotBase::RobotPeriodic() {
|
||||
static bool firstRun = true;
|
||||
@@ -71,7 +71,7 @@ void IterativeRobotBase::TeleopPeriodic() {
|
||||
}
|
||||
}
|
||||
|
||||
void IterativeRobotBase::TestPeriodic() {
|
||||
void IterativeRobotBase::UtilityPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
wpi::util::print("Default {}() method... Override me!\n", __FUNCTION__);
|
||||
@@ -85,7 +85,7 @@ void IterativeRobotBase::AutonomousExit() {}
|
||||
|
||||
void IterativeRobotBase::TeleopExit() {}
|
||||
|
||||
void IterativeRobotBase::TestExit() {}
|
||||
void IterativeRobotBase::UtilityExit() {}
|
||||
|
||||
wpi::units::second_t IterativeRobotBase::GetPeriod() const {
|
||||
return m_period;
|
||||
@@ -114,8 +114,8 @@ void IterativeRobotBase::LoopFunc() {
|
||||
AutonomousExit();
|
||||
} else if (m_lastMode == static_cast<int>(RobotMode::TELEOPERATED)) {
|
||||
TeleopExit();
|
||||
} else if (m_lastMode == static_cast<int>(RobotMode::TEST)) {
|
||||
TestExit();
|
||||
} else if (m_lastMode == static_cast<int>(RobotMode::UTILITY)) {
|
||||
UtilityExit();
|
||||
}
|
||||
|
||||
// Call current mode's entry function
|
||||
@@ -128,9 +128,9 @@ void IterativeRobotBase::LoopFunc() {
|
||||
} else if (mode == RobotMode::TELEOPERATED) {
|
||||
TeleopInit();
|
||||
m_watchdog.AddEpoch("TeleopInit()");
|
||||
} else if (mode == RobotMode::TEST) {
|
||||
TestInit();
|
||||
m_watchdog.AddEpoch("TestInit()");
|
||||
} else if (mode == RobotMode::UTILITY) {
|
||||
UtilityInit();
|
||||
m_watchdog.AddEpoch("UtilityInit()");
|
||||
}
|
||||
|
||||
m_lastMode = static_cast<int>(mode);
|
||||
@@ -147,9 +147,9 @@ void IterativeRobotBase::LoopFunc() {
|
||||
} else if (mode == RobotMode::TELEOPERATED) {
|
||||
TeleopPeriodic();
|
||||
m_watchdog.AddEpoch("TeleopPeriodic()");
|
||||
} else if (mode == RobotMode::TEST) {
|
||||
TestPeriodic();
|
||||
m_watchdog.AddEpoch("TestPeriodic()");
|
||||
} else if (mode == RobotMode::UTILITY) {
|
||||
UtilityPeriodic();
|
||||
m_watchdog.AddEpoch("UtilityPeriodic()");
|
||||
}
|
||||
|
||||
RobotPeriodic();
|
||||
|
||||
@@ -153,7 +153,7 @@ void MotorSafety::Check() {
|
||||
stopTime = m_stopTime;
|
||||
}
|
||||
|
||||
if (!enabled || RobotState::IsDisabled() || RobotState::IsTest()) {
|
||||
if (!enabled || RobotState::IsDisabled() || RobotState::IsUtility()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,12 +158,12 @@ bool RobotBase::IsTeleopEnabled() {
|
||||
return RobotState::IsTeleopEnabled();
|
||||
}
|
||||
|
||||
bool RobotBase::IsTest() {
|
||||
return RobotState::IsTest();
|
||||
bool RobotBase::IsUtility() {
|
||||
return RobotState::IsUtility();
|
||||
}
|
||||
|
||||
bool RobotBase::IsTestEnabled() {
|
||||
return RobotState::IsTestEnabled();
|
||||
bool RobotBase::IsUtilityEnabled() {
|
||||
return RobotState::IsUtilityEnabled();
|
||||
}
|
||||
|
||||
int64_t RobotBase::GetOpModeId() {
|
||||
|
||||
@@ -99,20 +99,22 @@ class RobotState final {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the DS is commanding test mode.
|
||||
* Check if the DS is commanding utility mode.
|
||||
*
|
||||
* @return True if the robot is being commanded to be in test mode
|
||||
* @return True if the robot is being commanded to be in utility mode
|
||||
*/
|
||||
static bool IsTest() { return wpi::internal::DriverStationBackend::IsTest(); }
|
||||
static bool IsUtility() {
|
||||
return wpi::internal::DriverStationBackend::IsUtility();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the DS is commanding Test mode and if it has enabled the robot.
|
||||
* Check if the DS is commanding Utility mode and if it has enabled the robot.
|
||||
*
|
||||
* @return True if the robot is being commanded to be in Test mode and
|
||||
* @return True if the robot is being commanded to be in Utility mode and
|
||||
* enabled.
|
||||
*/
|
||||
static bool IsTestEnabled() {
|
||||
return wpi::internal::DriverStationBackend::IsTestEnabled();
|
||||
static bool IsUtilityEnabled() {
|
||||
return wpi::internal::DriverStationBackend::IsUtilityEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -303,19 +303,19 @@ class DriverStationBackend final {
|
||||
static bool IsTeleopEnabled() { return GetControlWord().IsTeleopEnabled(); }
|
||||
|
||||
/**
|
||||
* Check if the DS is commanding test mode.
|
||||
* Check if the DS is commanding utility mode.
|
||||
*
|
||||
* @return True if the robot is being commanded to be in test mode
|
||||
* @return True if the robot is being commanded to be in utility mode
|
||||
*/
|
||||
static bool IsTest() { return GetControlWord().IsTest(); }
|
||||
static bool IsUtility() { return GetControlWord().IsUtility(); }
|
||||
|
||||
/**
|
||||
* Check if the DS is commanding Test mode and if it has enabled the robot.
|
||||
* Check if the DS is commanding Utility mode and if it has enabled the robot.
|
||||
*
|
||||
* @return True if the robot is being commanded to be in Test mode and
|
||||
* @return True if the robot is being commanded to be in Utility mode and
|
||||
* enabled.
|
||||
*/
|
||||
static bool IsTestEnabled() { return GetControlWord().IsTestEnabled(); }
|
||||
static bool IsUtilityEnabled() { return GetControlWord().IsUtilityEnabled(); }
|
||||
|
||||
/**
|
||||
* Adds an operating mode option. It's necessary to call PublishOpModes() to
|
||||
|
||||
@@ -32,8 +32,8 @@ namespace wpi {
|
||||
* 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
|
||||
* \li UtilityInit() -- called each and every time utility is entered from
|
||||
* another mode
|
||||
*
|
||||
* Periodic() functions -- each of these functions is called on an interval:
|
||||
*
|
||||
@@ -41,7 +41,7 @@ namespace wpi {
|
||||
* \li DisabledPeriodic()
|
||||
* \li AutonomousPeriodic()
|
||||
* \li TeleopPeriodic()
|
||||
* \li TestPeriodic()
|
||||
* \li UtilityPeriodic()
|
||||
*
|
||||
* Exit() functions -- each of the following functions is called once when the
|
||||
* appropriate mode is exited:
|
||||
@@ -49,7 +49,7 @@ namespace wpi {
|
||||
* \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
|
||||
* \li UtilityExit() -- called each and every time utility is exited
|
||||
*/
|
||||
class IterativeRobotBase : public RobotBase {
|
||||
public:
|
||||
@@ -97,12 +97,12 @@ class IterativeRobotBase : public RobotBase {
|
||||
virtual void TeleopInit();
|
||||
|
||||
/**
|
||||
* Initialization code for test mode should go here.
|
||||
* Initialization code for utility mode should go here.
|
||||
*
|
||||
* Users should override this method for initialization code which will be
|
||||
* called each time the robot enters test mode.
|
||||
* called each time the robot enters utility mode.
|
||||
*/
|
||||
virtual void TestInit();
|
||||
virtual void UtilityInit();
|
||||
|
||||
/**
|
||||
* Periodic code for all modes should go here.
|
||||
@@ -147,13 +147,13 @@ class IterativeRobotBase : public RobotBase {
|
||||
virtual void TeleopPeriodic();
|
||||
|
||||
/**
|
||||
* Periodic code for test mode should go here.
|
||||
* Periodic code for utility mode should go here.
|
||||
*
|
||||
* Users should override this method for code which will be called each time a
|
||||
* new packet is received from the driver station and the robot is in test
|
||||
* new packet is received from the driver station and the robot is in utility
|
||||
* mode.
|
||||
*/
|
||||
virtual void TestPeriodic();
|
||||
virtual void UtilityPeriodic();
|
||||
|
||||
/**
|
||||
* Exit code for disabled mode should go here.
|
||||
@@ -180,12 +180,12 @@ class IterativeRobotBase : public RobotBase {
|
||||
virtual void TeleopExit();
|
||||
|
||||
/**
|
||||
* Exit code for test mode should go here.
|
||||
* Exit code for utility mode should go here.
|
||||
*
|
||||
* Users should override this method for code which will be called each time
|
||||
* the robot exits test mode.
|
||||
* the robot exits utility mode.
|
||||
*/
|
||||
virtual void TestExit();
|
||||
virtual void UtilityExit();
|
||||
|
||||
/**
|
||||
* Gets time period between calls to Periodic() functions.
|
||||
|
||||
@@ -13,14 +13,11 @@
|
||||
#include "wpi/driverstation/Alert.hpp"
|
||||
#include "wpi/framework/RobotBase.hpp"
|
||||
#include "wpi/hal/DriverStationTypes.hpp"
|
||||
#include "wpi/hal/Notifier.h"
|
||||
#include "wpi/internal/PeriodicPriorityQueue.hpp"
|
||||
#include "wpi/opmode/OpMode.hpp"
|
||||
#include "wpi/system/Watchdog.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
#include "wpi/util/DenseMap.hpp"
|
||||
#include "wpi/util/SafeThread.hpp"
|
||||
#include "wpi/util/Synchronization.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace wpi::util {
|
||||
|
||||
@@ -191,20 +191,20 @@ class RobotBase {
|
||||
static bool IsTeleopEnabled();
|
||||
|
||||
/**
|
||||
* Determine if the robot is currently in Test mode.
|
||||
* Determine if the robot is currently in Utility mode.
|
||||
*
|
||||
* @return True if the robot is currently running in Test mode as determined
|
||||
* by the Driver Station.
|
||||
* @return True if the robot is currently running in Utility mode as
|
||||
* determined by the Driver Station.
|
||||
*/
|
||||
static bool IsTest();
|
||||
static bool IsUtility();
|
||||
|
||||
/**
|
||||
* Determine if the robot is current in Test mode and enabled.
|
||||
* Determine if the robot is currently in Utility mode and enabled.
|
||||
*
|
||||
* @return True if the robot is currently operating in Test mode while
|
||||
* @return True if the robot is currently operating in Utility mode while
|
||||
* enabled as determined by the Driver Station.
|
||||
*/
|
||||
static bool IsTestEnabled();
|
||||
static bool IsUtilityEnabled();
|
||||
|
||||
/**
|
||||
* Gets the currently selected operating mode of the driver station. Note this
|
||||
|
||||
Reference in New Issue
Block a user