OpModeRobot

class wpilib.OpModeRobot(*args, **kwargs)[source]

Bases: OpModeRobotBase

OpModeRobot implements the opmode-based robot program framework.

The OpModeRobot class is intended to be subclassed by a user creating a robot program.

Opmodes are constructed when selected on the driver station, and destroyed when the robot is disabled after being enabled or a different opmode is selected. When no opmode is selected, nonePeriodic() is called. The driverStationConnected() function is called the first time the driver station connects to the robot.

Overloaded function.

  1. __init__(self: wpilib._wpilib.OpModeRobotBase, period: wpimath.units.seconds) -> None

Constructor.

Parameters:

period – The period of the robot loop function.

  1. __init__(self: wpilib._wpilib.OpModeRobotBase) -> None

Constructor for an OpModeRobot with a default loop time of 0.02 seconds.

addOpMode(opmodeCls: type, mode: RobotMode, name: str, group: str | None = None, description: str | None = None, textColor: Color | None = None, backgroundColor: Color | None = None) None[source]

Adds an operating mode option. It’s necessary to call PublishOpModes() to make the added modes visible to the driver station.

The textColor and backgroundColor parameters are optional, but setting only one has no effect (if only one is provided, it will be ignored).

Parameters:
  • opmodeCls – opmode class; must be a public, non-abstract subclass of OpMode with a constructor that either takes no arguments or accepts a single argument of this class’s type (the latter is preferred).

  • mode – robot mode

  • name – name of the operating mode

  • group – group of the operating mode

  • description – description of the operating mode

  • textColor – text color

  • backgroundColor – background color