CommandXboxController

class commands2.button.CommandXboxController(port: int)[source]

Bases: CommandGenericHID

A version of XboxController with Trigger factories for command-based.

Construct an instance of a controller.

Parameters:

port – The port index on the Driver Station that the controller is plugged into.

a(loop: EventLoop | None = None) Trigger[source]

Constructs an event instance around the A button’s digital signal.

Parameters:

loop – the event loop instance to attach the event to, defaults to commands2.CommandScheduler.getDefaultButtonLoop()

Returns:

an event instance representing the A button’s digital signal attached to the given loop.

b(loop: EventLoop | None = None) Trigger[source]

Constructs an event instance around the B button’s digital signal.

Parameters:

loop – the event loop instance to attach the event to, defaults to commands2.CommandScheduler.getDefaultButtonLoop()

Returns:

an event instance representing the B button’s digital signal attached to the given loop.

back(loop: EventLoop | None = None) Trigger[source]

Constructs an event instance around the back button’s digital signal.

Parameters:

loop – the event loop instance to attach the event to, defaults to commands2.CommandScheduler.getDefaultButtonLoop()

Returns:

an event instance representing the back button’s digital signal attached to the given loop.

getHID() XboxController[source]

Get the underlying GenericHID object.

Returns:

the wrapped GenericHID object

getLeftTriggerAxis() float[source]

Get the left trigger (LT) axis value of the controller. Note that this axis is bound to the range of [0, 1] as opposed to the usual [-1, 1].

Returns:

The axis value.

getLeftX() float[source]

Get the X axis value of left side of the controller.

Returns:

The axis value.

getLeftY() float[source]

Get the Y axis value of left side of the controller.

Returns:

The axis value.

getRightTriggerAxis() float[source]

Get the right trigger (RT) axis value of the controller. Note that this axis is bound to the range of [0, 1] as opposed to the usual [-1, 1].

Returns:

The axis value.

getRightX() float[source]

Get the X axis value of right side of the controller.

Returns:

The axis value.

getRightY() float[source]

Get the Y axis value of right side of the controller.

Returns:

The axis value.

leftBumper(loop: EventLoop | None = None) Trigger[source]

Constructs an event instance around the left bumper’s digital signal.

Parameters:

loop – the event loop instance to attach the event to, defaults to commands2.CommandScheduler.getDefaultButtonLoop()

Returns:

an event instance representing the right bumper’s digital signal attached to the given loop.

leftStick(loop: EventLoop | None = None) Trigger[source]

Constructs an event instance around the left stick button’s digital signal.

Parameters:

loop – the event loop instance to attach the event to, defaults to commands2.CommandScheduler.getDefaultButtonLoop()

Returns:

an event instance representing the left stick button’s digital signal attached to the given loop.

leftTrigger(threshold: float = 0.5, loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the axis value of the left trigger. The returned trigger will be true when the axis value is greater than {@code threshold}.

Parameters:
  • threshold – the minimum axis value for the returned Trigger to be true. This value should be in the range [0, 1] where 0 is the unpressed state of the axis.

  • loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.getDefaultButtonLoop()

Returns:

a Trigger instance that is true when the left trigger’s axis exceeds the provided threshold, attached to the given event loop

rightBumper(loop: EventLoop | None = None) Trigger[source]

Constructs an event instance around the right bumper’s digital signal.

Parameters:

loop – the event loop instance to attach the event to, defaults to commands2.CommandScheduler.getDefaultButtonLoop()

Returns:

an event instance representing the left bumper’s digital signal attached to the given loop.

rightStick(loop: EventLoop | None = None) Trigger[source]

Constructs an event instance around the right stick button’s digital signal.

Parameters:

loop – the event loop instance to attach the event to, defaults to commands2.CommandScheduler.getDefaultButtonLoop()

Returns:

an event instance representing the right stick button’s digital signal attached to the given loop.

rightTrigger(threshold: float = 0.5, loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the axis value of the right trigger. The returned trigger will be true when the axis value is greater than {@code threshold}.

Parameters:
  • threshold – the minimum axis value for the returned Trigger to be true. This value should be in the range [0, 1] where 0 is the unpressed state of the axis.

  • loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.getDefaultButtonLoop()

Returns:

a Trigger instance that is true when the right trigger’s axis exceeds the provided threshold, attached to the given event loop

start(loop: EventLoop | None = None) Trigger[source]

Constructs an event instance around the start button’s digital signal.

Parameters:

loop – the event loop instance to attach the event to, defaults to commands2.CommandScheduler.getDefaultButtonLoop()

Returns:

an event instance representing the start button’s digital signal attached to the given loop.

x(loop: EventLoop | None = None) Trigger[source]

Constructs an event instance around the X button’s digital signal.

Parameters:

loop – the event loop instance to attach the event to, defaults to commands2.CommandScheduler.getDefaultButtonLoop()

Returns:

an event instance representing the X button’s digital signal attached to the given loop.

y(loop: EventLoop | None = None) Trigger[source]

Constructs an event instance around the Y button’s digital signal.

Parameters:

loop – the event loop instance to attach the event to, defaults to commands2.CommandScheduler.getDefaultButtonLoop()

Returns:

an event instance representing the Y button’s digital signal attached to the given loop.