Skip to content

Controller input

Controller input is exposed through robot.controller. The data is cached and read immediately; property access does not block for a new packet.

Controller

Controller(state_mirror=None)

Students normally use the instance owned by Robot, rather than constructing a Controller directly.

Attributes

controller.left_stick: Joystick
controller.right_stick: Joystick

button

controller.button(name: str) -> Button

Returns a cached button object. Names are converted to uppercase.

Raises ValueError when name is empty. The current API does not validate names against a fixed hardware list.

Joystick

Joystick(side: str, state_mirror=None)

Students normally obtain joysticks from Controller.

Properties

Property Type Meaning Default before data
x float Scaled X axis, intended range −100 to 100 0.0
y float Scaled Y axis, intended range −100 to 100 0.0
raw_x int Raw 12-bit ADC X 2048
raw_y int Raw 12-bit ADC Y 2048

Button

Button(name: str, state_mirror=None)

Students normally obtain buttons through Controller.button().

is_down: bool

True while the button is currently pressed. This is a level, not a press/release event.

previous = False
while robot.running:
    current = robot.controller.button("A").is_down
    if current and not previous:
        toggle_arm()
    previous = current