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, none_periodic() is called. The driver_station_connected() 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.

add_opmode(opmode_cls: type, mode: RobotMode, name: str, group: str | None = None, description: str | None = None, text_color: Color | None = None, background_color: Color | None = None) None[source]

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

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

Parameters:
  • opmode_cls – 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

  • text_color – text color

  • background_color – background color