OpMode
- class wpilib.OpMode
Bases:
pybind11_objectTop-level interface for opmode classes. Users should generally extend one of the abstract implementations of this interface (e.g. PeriodicOpMode) rather than directly implementing this interface.
Lifecycle:
constructed when opmode selected on driver station
DisabledPeriodic() called periodically as long as DS is disabled
when DS transitions from disabled to enabled, Start() is called once
while DS is enabled, Periodic() is called periodically and additional
periodic callbacks added via GetCallbacks() are called periodically - when DS transitions from enabled to disabled, or a different opmode is selected while enabled, End() is called, followed by Close(); the object is not reused - if a different opmode is selected while disabled, only Close() is called; the object is not reused
- disabledPeriodic() None
This function is called periodically while the opmode is selected on the DS (robot is disabled). Code that should only run once when the opmode is selected should go in the opmode constructor.
- end() None
This function is called when the robot disables or switches opmodes while this opmode is enabled. Implementations should stop blocking work promptly.
- getCallbacks() list[wpilib._wpilib.PeriodicPriorityQueue.Callback]
Returns a vector of custom periodic callbacks to be executed while the opmode is enabled.
This method allows opmodes to register arbitrary periodic callbacks with custom execution intervals. The callbacks are executed by the robot framework at their scheduled times, in addition to the primary Periodic() callback.
- Returns:
A vector of custom callbacks to execute, or an empty vector if no custom callbacks are needed. The default implementation returns an empty vector.
- periodic() None
This function is called periodically while the opmode is enabled.
- start() None
Called once when this opmode transitions to enabled.