Class RobotState
java.lang.Object
org.wpilib.driverstation.RobotState
Provides access to robot state information from the Driver Station.
-
Method Summary
Modifier and TypeMethodDescriptionstatic longAdds an operating mode option.static longAdds an operating mode option.static longAdds an operating mode option.static longaddOpMode(RobotMode mode, String name, String group, String description, Color textColor, Color backgroundColor) Adds an operating mode option.static voidClears all operating mode options and publishes an empty list to the driver station.static StringGets the operating mode selected on the driver station.static longGets the operating mode selected on the driver station.static RobotModeGets the current robot mode.static booleanGets a value indicating whether the Driver Station requires the robot to be running in autonomous mode.static booleanGets a value indicating whether the Driver Station requires the robot to be running in autonomous mode and enabled.static booleanGets a value indicating whether the Driver Station requires the robot to be disabled.static booleanGets a value indicating whether the Driver Station is attached.static booleanGets a value indicating whether the Driver Station requires the robot to be enabled.static booleanGets a value indicating whether the Robot is e-stopped.static booleanGets if the driver station attached to a Field Management System.static booleanisOpMode(long id) Check to see if the selected operating mode is a particular value.static booleanCheck to see if the selected operating mode is a particular value.static booleanisTeleop()Gets a value indicating whether the Driver Station requires the robot to be running in operator-controlled mode.static booleanGets a value indicating whether the Driver Station requires the robot to be running in operator-controller mode and enabled.static booleanGets a value indicating whether the Driver Station requires the robot to be running in Utility mode.static booleanGets a value indicating whether the Driver Station requires the robot to be running in Utility mode and enabled.static voidPublishes the operating mode options to the driver station.static longremoveOpMode(RobotMode mode, String name) Removes an operating mode option.
-
Method Details
-
isEnabled
Gets a value indicating whether the Driver Station requires the robot to be enabled.- Returns:
- True if the robot is enabled, false otherwise.
-
isDisabled
Gets a value indicating whether the Driver Station requires the robot to be disabled.- Returns:
- True if the robot should be disabled, false otherwise.
-
isEStopped
Gets a value indicating whether the Robot is e-stopped.- Returns:
- True if the robot is e-stopped, false otherwise.
-
getRobotMode
Gets the current robot mode.Note that this does not indicate whether the robot is enabled or disabled.
- Returns:
- robot mode
-
isAutonomous
Gets a value indicating whether the Driver Station requires the robot to be running in autonomous mode.- Returns:
- True if autonomous mode should be enabled, false otherwise.
-
isAutonomousEnabled
Gets a value indicating whether the Driver Station requires the robot to be running in autonomous mode and enabled.- Returns:
- True if autonomous should be set and the robot should be enabled.
-
isTeleop
Gets a value indicating whether the Driver Station requires the robot to be running in operator-controlled mode.- Returns:
- True if operator-controlled mode should be enabled, false otherwise.
-
isTeleopEnabled
Gets a value indicating whether the Driver Station requires the robot to be running in operator-controller mode and enabled.- Returns:
- True if operator-controlled mode should be set and the robot should be enabled.
-
isUtility
Gets a value indicating whether the Driver Station requires the robot to be running in Utility mode.- Returns:
- True if utility mode should be enabled, false otherwise.
-
isUtilityEnabled
Gets a value indicating whether the Driver Station requires the robot to be running in Utility mode and enabled.- Returns:
- True if utility mode should be set and the robot should be enabled.
-
addOpMode
public static long addOpMode(RobotMode mode, String name, String group, String description, Color textColor, Color backgroundColor) Adds an operating mode option. It's necessary to call publishOpModes() to make the added modes visible to the driver station.- Parameters:
mode- robot modename- name of the operating modegroup- group of the operating modedescription- description of the operating modetextColor- text color, or null for defaultbackgroundColor- background color, or null for default- Returns:
- unique ID used to later identify the operating mode
- Throws:
IllegalArgumentException- if name is empty or an operating mode with the same robot mode and name already exists
-
addOpMode
Adds an operating mode option. It's necessary to call publishOpModes() to make the added modes visible to the driver station.- Parameters:
mode- robot modename- name of the operating modegroup- group of the operating modedescription- description of the operating mode- Returns:
- unique ID used to later identify the operating mode
- Throws:
IllegalArgumentException- if name is empty or an operating mode with the same name already exists
-
addOpMode
Adds an operating mode option. It's necessary to call publishOpModes() to make the added modes visible to the driver station.- Parameters:
mode- robot modename- name of the operating modegroup- group of the operating mode- Returns:
- unique ID used to later identify the operating mode
- Throws:
IllegalArgumentException- if name is empty or an operating mode with the same name already exists
-
addOpMode
Adds an operating mode option. It's necessary to call publishOpModes() to make the added modes visible to the driver station.- Parameters:
mode- robot modename- name of the operating mode- Returns:
- unique ID used to later identify the operating mode
- Throws:
IllegalArgumentException- if name is empty or an operating mode with the same name already exists
-
removeOpMode
Removes an operating mode option. It's necessary to call publishOpModes() to make the removed mode no longer visible to the driver station.- Parameters:
mode- robot modename- name of the operating mode- Returns:
- unique ID for the opmode, or 0 if not found
-
publishOpModes
Publishes the operating mode options to the driver station. -
clearOpModes
Clears all operating mode options and publishes an empty list to the driver station. -
getOpModeId
Gets the operating mode selected on the driver station. Note this does not mean the robot is enabled; use isEnabled() for that. In a match, this will indicate the operating mode selected for auto before the match starts (i.e., while the robot is disabled in auto mode); after the auto period ends, this will change to reflect the operating mode selected for teleop.- Returns:
- the unique ID provided by the addOpMode() function; may return 0 or a unique ID not added, so callers should be prepared to handle that case
-
getOpMode
Gets the operating mode selected on the driver station. Note this does not mean the robot is enabled; use isEnabled() for that. In a match, this will indicate the operating mode selected for auto before the match starts (i.e., while the robot is disabled in auto mode); after the auto period ends, this will change to reflect the operating mode selected for teleop.- Returns:
- Operating mode string; may return a string not in the list of options, so callers should be prepared to handle that case
-
isOpMode
Check to see if the selected operating mode is a particular value. Note this does not mean the robot is enabled; use isEnabled() for that.- Parameters:
id- operating mode unique ID- Returns:
- True if that mode is the current mode
-
isOpMode
-
isDSAttached
Gets a value indicating whether the Driver Station is attached.- Returns:
- True if Driver Station is attached, false otherwise.
-
isFMSAttached
Gets if the driver station attached to a Field Management System.- Returns:
- true if the robot is competing on a field being controlled by a Field Management System
-