mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +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:
@@ -181,23 +181,23 @@ public class ControlWord {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value indicating whether the Driver Station requires the robot to be running in test
|
||||
* Gets a value indicating whether the Driver Station requires the robot to be running in utility
|
||||
* mode.
|
||||
*
|
||||
* @return True if test mode should be enabled, false otherwise.
|
||||
* @return True if utility mode should be enabled, false otherwise.
|
||||
*/
|
||||
public boolean isTest() {
|
||||
return getRobotMode() == RobotMode.TEST;
|
||||
public boolean isUtility() {
|
||||
return getRobotMode() == RobotMode.UTILITY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value indicating whether the Driver Station requires the robot to be running in test
|
||||
* Gets a value indicating whether the Driver Station requires the robot to be running in utility
|
||||
* mode and enabled.
|
||||
*
|
||||
* @return True if test mode should be set and the robot should be enabled.
|
||||
* @return True if utility mode should be set and the robot should be enabled.
|
||||
*/
|
||||
public boolean isTestEnabled() {
|
||||
return isTest() && isEnabled() && isDSAttached();
|
||||
public boolean isUtilityEnabled() {
|
||||
return isUtility() && isEnabled() && isDSAttached();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,8 +12,8 @@ public enum RobotMode {
|
||||
AUTONOMOUS(1),
|
||||
/** Teleoperated. */
|
||||
TELEOPERATED(2),
|
||||
/** Test. */
|
||||
TEST(3);
|
||||
/** Utility. */
|
||||
UTILITY(3);
|
||||
|
||||
private final int value;
|
||||
|
||||
@@ -35,7 +35,7 @@ public enum RobotMode {
|
||||
return switch (value) {
|
||||
case 1 -> AUTONOMOUS;
|
||||
case 2 -> TELEOPERATED;
|
||||
case 3 -> TEST;
|
||||
case 3 -> UTILITY;
|
||||
default -> UNKNOWN;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ControlWordStruct implements Struct<ControlWord> {
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return "uint64 opModeHash:56;"
|
||||
+ "enum{unknown=0,autonomous=1,teleoperated=2,test=3} uint64 robotMode:2;"
|
||||
+ "enum{unknown=0,autonomous=1,teleoperated=2,utility=3} uint64 robotMode:2;"
|
||||
+ "bool enabled:1;bool eStop:1;bool fmsAttached:1;bool dsAttached:1;";
|
||||
}
|
||||
|
||||
|
||||
@@ -99,13 +99,13 @@ struct DashboardOpModeInstance {
|
||||
void Start(nt::NetworkTableInstance inst) {
|
||||
autoOpModes.Start(inst, "/SmartDashboard/Auto OpMode");
|
||||
teleopOpModes.Start(inst, "/SmartDashboard/Teleop OpMode");
|
||||
testOpModes.Start(inst, "/SmartDashboard/Test OpMode");
|
||||
utilityOpModes.Start(inst, "/SmartDashboard/Utility OpMode");
|
||||
}
|
||||
|
||||
util::mutex mutex;
|
||||
DashboardOpModeSender autoOpModes;
|
||||
DashboardOpModeSender teleopOpModes;
|
||||
DashboardOpModeSender testOpModes;
|
||||
DashboardOpModeSender utilityOpModes;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -122,7 +122,7 @@ void hal::SetDashboardOpModeOptions(std::span<const HAL_OpModeOption> options) {
|
||||
std::scoped_lock lock{gInstance->mutex};
|
||||
gInstance->autoOpModes.SetOptions(options, HAL_ROBOT_MODE_AUTONOMOUS);
|
||||
gInstance->teleopOpModes.SetOptions(options, HAL_ROBOT_MODE_TELEOPERATED);
|
||||
gInstance->testOpModes.SetOptions(options, HAL_ROBOT_MODE_TEST);
|
||||
gInstance->utilityOpModes.SetOptions(options, HAL_ROBOT_MODE_UTILITY);
|
||||
}
|
||||
|
||||
void hal::StartDashboardOpMode() {
|
||||
@@ -141,7 +141,7 @@ void hal::EnableDashboardOpMode() {
|
||||
std::scoped_lock lock{gInstance->mutex};
|
||||
gInstance->autoOpModes.Enable();
|
||||
gInstance->teleopOpModes.Enable();
|
||||
gInstance->testOpModes.Enable();
|
||||
gInstance->utilityOpModes.Enable();
|
||||
}
|
||||
|
||||
int64_t hal::GetDashboardSelectedOpMode(HAL_RobotMode robotMode) {
|
||||
@@ -154,8 +154,8 @@ int64_t hal::GetDashboardSelectedOpMode(HAL_RobotMode robotMode) {
|
||||
return gInstance->autoOpModes.GetSelected();
|
||||
case HAL_ROBOT_MODE_TELEOPERATED:
|
||||
return gInstance->teleopOpModes.GetSelected();
|
||||
case HAL_ROBOT_MODE_TEST:
|
||||
return gInstance->testOpModes.GetSelected();
|
||||
case HAL_ROBOT_MODE_UTILITY:
|
||||
return gInstance->utilityOpModes.GetSelected();
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ HAL_ENUM(HAL_RobotMode) {
|
||||
HAL_ROBOT_MODE_UNKNOWN = 0,
|
||||
HAL_ROBOT_MODE_AUTONOMOUS,
|
||||
HAL_ROBOT_MODE_TELEOPERATED,
|
||||
HAL_ROBOT_MODE_TEST,
|
||||
HAL_ROBOT_MODE_UTILITY,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,8 +19,8 @@ enum class RobotMode {
|
||||
AUTONOMOUS = HAL_ROBOT_MODE_AUTONOMOUS,
|
||||
/// Teleoperated.
|
||||
TELEOPERATED = HAL_ROBOT_MODE_TELEOPERATED,
|
||||
/// Test.
|
||||
TEST = HAL_ROBOT_MODE_TEST
|
||||
/// Utility.
|
||||
UTILITY = HAL_ROBOT_MODE_UTILITY
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -174,20 +174,20 @@ class ControlWord {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
bool IsTest() const { return GetRobotMode() == RobotMode::TEST; }
|
||||
bool IsUtility() const { return GetRobotMode() == RobotMode::UTILITY; }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
bool IsTestEnabled() const {
|
||||
return IsTest() && IsEnabled() && IsDSAttached();
|
||||
bool IsUtilityEnabled() const {
|
||||
return IsUtility() && IsEnabled() && IsDSAttached();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,7 +217,7 @@ struct wpi::util::Struct<wpi::hal::ControlWord> {
|
||||
static constexpr size_t GetSize() { return 8; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
return "uint64 opModeHash:56;"
|
||||
"enum{unknown=0,autonomous=1,teleoperated=2,test=3}"
|
||||
"enum{unknown=0,autonomous=1,teleoperated=2,utility=3}"
|
||||
"uint64 robotMode:2;"
|
||||
"bool enabled:1;bool eStop:1;bool fmsAttached:1;bool dsAttached:1;";
|
||||
}
|
||||
|
||||
@@ -29,6 +29,6 @@ classes:
|
||||
IsAutonomousEnabled:
|
||||
IsTeleop:
|
||||
IsTeleopEnabled:
|
||||
IsTest:
|
||||
IsTestEnabled:
|
||||
IsUtility:
|
||||
IsUtilityEnabled:
|
||||
GetValue:
|
||||
|
||||
Reference in New Issue
Block a user