RobotBase
- class wpilib.RobotBase
Bases:
pybind11_objectImplement a Robot Program framework. The RobotBase class is intended to be subclassed to create a robot program. The user must implement StartCompetition() which will be called once and is not expected to exit. The user must also implement EndCompetition(), which signals to the code in StartCompetition() that it should exit.
It is not recommended to subclass this class directly - instead subclass IterativeRobotBase or TimedRobot.
Constructor for a generic robot program.
User code can 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.
- endCompetition() None
Ends the main loop in StartCompetition().
- static getOpMode() str
Gets the currently selected operating mode of the driver station. Note this does not mean the robot is enabled; use IsEnabled() for that.
- Returns:
Operating mode string; may return a string not in the list of options, so callers should be prepared to handle that case
- static getOpModeId() int
Gets the currently selected operating mode of the driver station. Note this does not mean the robot is enabled; use IsEnabled() for that.
- Returns:
the unique ID provided by the RobotState::AddOpMode() function; may return 0 or a unique ID not added, so callers should be prepared to handle that case
- static getRuntimeType() wpilib._wpilib.RuntimeType
Get the current runtime type.
- Returns:
Current runtime type.
- static isAutonomous() bool
Determine if the robot is currently in Autonomous mode.
- Returns:
True if the robot is currently operating Autonomously as determined by the Driver Station.
- static isAutonomousEnabled() bool
Determine if the robot is currently in Autonomous mode and enabled.
- Returns:
True if the robot us currently operating Autonomously while enabled as determined by the Driver Station.
- static isDisabled() bool
Determine if the Robot is currently disabled.
- Returns:
True if the Robot is currently disabled by the Driver Station.
- static isEnabled() bool
Determine if the Robot is currently enabled.
- Returns:
True if the Robot is currently enabled by the Driver Station.
- static isReal() bool
Get if the robot is real.
- Returns:
If the robot is running in the real world.
- static isSimulation() bool
Get if the robot is a simulation.
- Returns:
If the robot is running in simulation.
- static isTeleop() bool
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 Driver Station.
- static isTeleopEnabled() bool
Determine if the robot is current in Operator Control mode and enabled.
- Returns:
True if the robot is currently operating in Tele-Op mode while enabled as determined by the Driver Station.
- static isUtility() bool
Determine if the robot is currently in Utility mode.
- Returns:
True if the robot is currently running in Utility mode as determined by the Driver Station.
- static isUtilityEnabled() bool
Determine if the robot is currently in Utility mode and enabled.
- Returns:
True if the robot is currently operating in Utility mode while enabled as determined by the Driver Station.
- logger = <Logger robot (WARNING)>
- static main(robot_cls: object) object
Starting point for the application
- startCompetition() None
Start the main robot code. This function will be called once and should not exit until signalled by EndCompetition()