Controller Input Module#

Handles remote controller input for the robot.

This model is really only functional and practical when on native hardware, paired with the official Unitree Go2 Controller. It doesn’t do anything on virtual hardware.

This module allows users to:
  • Access the current controller state

  • Register callbacks for specific input signals (buttons, sticks, triggers)

  • Cleanly shutdown input resources (handled automatically)

Internally, it wraps the low-level Unitree SDK or controller parser, but users interact only with the high-level InputModule interface.

class go2.modules.input.input_module.InputModule[source]#

Bases: DogModule

Users should not access or construct this class directly. Rather, they should access it through the Go2Controller instance.

register_callback(signal: InputSignal, callback: Callable[[ControllerState], None], name: str | None = None, threshold: float = 0.1)[source]#

Register a callback for a specific controller signal.

Parameters:
  • signal (InputSignal) – The input signal to monitor (e.g., BUTTON_A, LEFT_STICK_X)

  • callback (Callable[[ControllerState], None]) – Function to call when the signal triggers

  • name (str, optional) – Optional human-readable name for the callback

  • threshold (float, optional) – Threshold for analog inputs (default 0.1)

Returns:

Registered callback object

Return type:

Callback

unregister_callback(signal: InputSignal, callback: Callable[[ControllerState], None]) None[source]#

Unregister a previously registered callback.

Parameters:
  • signal (InputSignal) – The signal whose callback should be removed

  • callback (Callable[[ControllerState], None]) – The previously registered callback function

class go2.modules.input.input_signal.InputSignal(value)[source]#

Bases: Enum

Enumeration of all possible controller input signals.

Internal mapping from logical signal names to string identifiers used by the system for tracking and callback triggering.

Members#

  • LEFT_STICK, RIGHT_STICK : Stick identifiers

  • LEFT_STICK_X, LEFT_STICK_Y, RIGHT_STICK_X, RIGHT_STICK_Y : Stick axes

  • LEFT_TRIGGER, RIGHT_TRIGGER : Analog triggers

  • LEFT_BUMPER, RIGHT_BUMPER : Bumper buttons

  • BUTTON_A, BUTTON_B, BUTTON_X, BUTTON_Y : Face buttons

  • DPAD_UP, DPAD_DOWN, DPAD_LEFT, DPAD_RIGHT : Directional pad

  • SELECT, START, F1, F3 : Other buttons

BUTTON_A = 'a'#
BUTTON_B = 'b'#
BUTTON_X = 'x'#
BUTTON_Y = 'y'#
DPAD_DOWN = 'down'#
DPAD_LEFT = 'left'#
DPAD_RIGHT = 'right'#
DPAD_UP = 'up'#
F1 = 'f1'#
F3 = 'f3'#
LEFT_BUMPER = 'l1'#
LEFT_STICK = 'left_stick'#
LEFT_STICK_X = 'lx'#
LEFT_STICK_Y = 'ly'#
LEFT_TRIGGER = 'l2'#
RIGHT_BUMPER = 'r1'#
RIGHT_STICK = 'right_stick'#
RIGHT_STICK_X = 'rx'#
RIGHT_STICK_Y = 'ry'#
RIGHT_TRIGGER = 'r2'#
SELECT = 'select'#
START = 'start'#
class go2.modules.input.controller_state.ControllerState(lx: float = 0.0, ly: float = 0.0, rx: float = 0.0, ry: float = 0.0, l1: float = 0.0, l2: float = 0.0, r1: float = 0.0, r2: float = 0.0, a: float = 0.0, b: float = 0.0, x: float = 0.0, y: float = 0.0, up: float = 0.0, down: float = 0.0, left: float = 0.0, right: float = 0.0, select: float = 0.0, start: float = 0.0, f1: float = 0.0, f3: float = 0.0, changed: bool = False)[source]#

Bases: object

Represents the current state of a controller’s inputs.

Tracks analog and digital values for sticks, triggers, and buttons, along with a flag indicating whether any input has changed since the last update.

a: float = 0.0#

‘A’ button

b: float = 0.0#

‘B’ button

changed: bool = False#
down: float = 0.0#

D-pad down

f1: float = 0.0#

F1 button

f3: float = 0.0#

F3 button

l1: float = 0.0#

Left bumper

l2: float = 0.0#

Left trigger

left: float = 0.0#

D-pad left

lx: float = 0.0#

Left stick X-axis

ly: float = 0.0#

Left stick Y-axis

r1: float = 0.0#

Right bumper

r2: float = 0.0#

Right trigger

right: float = 0.0#

D-pad right

rx: float = 0.0#

Right stick X-axis

ry: float = 0.0#

Right stick Y-axis

select: float = 0.0#

Select button

start: float = 0.0#

Start button

up: float = 0.0#

D-pad up

x: float = 0.0#

‘X’ button

y: float = 0.0#

‘Y’ button