RobotBase

class wpilib.RobotBase[source]

Bases: builtins.object

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.

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.

Warning

If you override __init__ in your robot class, you must call the base class constructor. This must be used to ensure that the communications code starts.

free()[source]

Free the resources for a RobotBase class.

static initializeHardwareConfiguration()[source]

Common initialization for all robot programs.

isAutonomous()[source]

Determine if the robot is currently in Autonomous mode.

Returns:True if the robot is currently operating Autonomously as determined by the field controls.
Return type:bool
isDisabled()[source]

Determine if the Robot is currently disabled.

Returns:True if the Robot is currently disabled by the field controls.
Return type:bool
isEnabled()[source]

Determine if the Robot is currently enabled.

Returns:True if the Robot is currently enabled by the field controls.
Return type:bool
isNewDataAvailable()[source]

Indicates 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?
Return type:bool
isOperatorControl()[source]

Determine if the robot is currently in Operator Control mode.

Returns:True if the robot is currently operating in Tele-Op mode as determined by the field controls.
Return type:bool
static isReal()[source]
Returns:If the robot is running in the real world.
Return type:bool
static isSimulation()[source]
Returns:If the robot is running in simulation.
Return type:bool
isTest()[source]

Determine if the robot is currently in Test mode.

Returns:True if the robot is currently operating in Test mode as determined by the driver station.
Return type:bool
static main(robot_cls)[source]

Starting point for the applications.

prestart()[source]

This hook is called right before startCompetition(). By default, tell the DS that the robot is now ready to be enabled. If you don’t want the robot to be enabled yet, you can override this method to do nothing. If you do so, you will need to call hal.HALNetworkCommunicationObserveUserProgramStarting() from your code when you are ready for the robot to be enabled.

startCompetition()[source]

Provide an alternate “main loop” via startCompetition().