Package edu.wpi.first.wpilibj
Class RobotBase
java.lang.Object
edu.wpi.first.wpilibj.RobotBase
- All Implemented Interfaces:
- AutoCloseable
- Direct Known Subclasses:
- IterativeRobotBase
public abstract class RobotBase extends Object implements AutoCloseable
Implement a Robot Program framework. The RobotBase class is intended to be subclassed by a user
 creating a robot program. Overridden autonomous() and operatorControl() methods are called at the
 appropriate time as the match proceeds. In the current implementation, the Autonomous code will
 run to completion before the OperatorControl code could start. In the future the Autonomous code
 might be spawned as a task, then killed at the end of the Autonomous period.
- 
Constructor SummaryConstructors Modifier Constructor Description protectedRobotBase()Constructor for a generic robot program.
- 
Method SummaryModifier and Type Method Description voidclose()abstract voidendCompetition()Ends the main loop in startCompetition().static booleangetBooleanProperty(String name, boolean defaultValue)static longgetMainThreadId()static RuntimeTypegetRuntimeType()Get the current runtime type.booleanisAutonomous()Determine if the robot is currently in Autonomous mode as determined by the field controls.booleanisAutonomousEnabled()Determine if the robot is current in Autonomous mode and enabled as determined by the field controls.booleanisDisabled()Determine if the Robot is currently disabled.booleanisEnabled()Determine if the Robot is currently enabled.booleanisNewDataAvailable()Indicates if new data is available from the driver station.booleanisOperatorControl()Deprecated, for removal: This API element is subject to removal in a future version.Use isTeleop() instead.booleanisOperatorControlEnabled()Deprecated, for removal: This API element is subject to removal in a future version.Use isTeleopEnabled() instead.static booleanisReal()Get if the robot is real.static booleanisSimulation()Get if the robot is a simulation.booleanisTeleop()Determine if the robot is currently in Operator Control mode as determined by the field controls.booleanisTeleopEnabled()Determine if the robot is current in Operator Control mode and enabled as determined by the field controls.booleanisTest()Determine if the robot is currently in Test mode as determined by the driver station.abstract voidstartCompetition()Provide an alternate "main loop" via startCompetition().static <T extends RobotBase>
 voidstartRobot(Supplier<T> robotSupplier)Starting point for the applications.static voidsuppressExitWarning(boolean value)Suppress the "The robot program quit unexpectedly." message.
- 
Constructor Details- 
RobotBaseprotected RobotBase()Constructor for a generic robot program. User code should be placed in the constructor that runs before the Autonomous or Operator Control period starts. The constructor will run to completion before Autonomous is entered.This must be used to ensure that the communications code starts. In the future it would be nice to put this code into it's own task that loads on boot so ensure that it runs. 
 
- 
- 
Method Details- 
getMainThreadId
- 
close- Specified by:
- closein interface- AutoCloseable
 
- 
getRuntimeTypeGet the current runtime type.- Returns:
- Current runtime type.
 
- 
isSimulationGet if the robot is a simulation.- Returns:
- If the robot is running in simulation.
 
- 
isRealGet if the robot is real.- Returns:
- If the robot is running in the real world.
 
- 
isDisabledDetermine if the Robot is currently disabled.- Returns:
- True if the Robot is currently disabled by the field controls.
 
- 
isEnabledDetermine if the Robot is currently enabled.- Returns:
- True if the Robot is currently enabled by the field controls.
 
- 
isAutonomousDetermine if the robot is currently in Autonomous mode as determined by the field controls.- Returns:
- True if the robot is currently operating Autonomously.
 
- 
isAutonomousEnabledDetermine if the robot is current in Autonomous mode and enabled as determined by the field controls.- Returns:
- True if the robot is currently operating autonomously while enabled.
 
- 
isTestDetermine if the robot is currently in Test mode as determined by the driver station.- Returns:
- True if the robot is currently operating in Test mode.
 
- 
isOperatorControlDeprecated, for removal: This API element is subject to removal in a future version.Use isTeleop() instead.Determine if the robot is currently in Operator Control mode as determined by the field controls.- Returns:
- True if the robot is currently operating in Tele-Op mode.
 
- 
isTeleopDetermine if the robot is currently in Operator Control mode as determined by the field controls.- Returns:
- True if the robot is currently operating in Tele-Op mode.
 
- 
isOperatorControlEnabledDeprecated, for removal: This API element is subject to removal in a future version.Use isTeleopEnabled() instead.Determine if the robot is current in Operator Control mode and enabled as determined by the field controls.- Returns:
- True if the robot is currently operating in Tele-Op mode while enabled.
 
- 
isTeleopEnabledDetermine if the robot is current in Operator Control mode and enabled as determined by the field controls.- Returns:
- True if the robot is currently operating in Tele-Op mode while enabled.
 
- 
isNewDataAvailableIndicates if new data is available from the driver station.- Returns:
- Has new data arrived over the network since the last time this function was called?
 
- 
startCompetitionProvide an alternate "main loop" via startCompetition().
- 
endCompetitionEnds the main loop in startCompetition().
- 
getBooleanProperty
- 
suppressExitWarningSuppress the "The robot program quit unexpectedly." message.- Parameters:
- value- True if exit warning should be suppressed.
 
- 
startRobotStarting point for the applications.- Type Parameters:
- T- Robot subclass.
- Parameters:
- robotSupplier- Function that returns an instance of the robot subclass.
 
 
-