CommandJoystick

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

Bases: CommandGenericHID

A version of wpilib.Joystick 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.

getDirectionDegrees() float[source]

Get the direction of the vector formed by the joystick and its origin in degrees.

Returns:

The direction of the vector in degrees

getDirectionRadians() float[source]

Get the direction of the vector formed by the joystick and its origin in radians.

Returns:

The direction of the vector in radians

getHID() Joystick[source]

Get the underlying GenericHID object.

Returns:

the wrapped GenericHID object

getMagnitude() float[source]

Get the magnitude of the direction vector formed by the joystick’s current position relative to its origin.

Returns:

The magnitude of the direction vector

getThrottle() float[source]

Get the throttle value of the current joystick. This depends on the mapping of the joystick connected to the current port.

Returns:

The Throttle value of the joystick.

getThrottleChannel() int[source]

Get the channel currently associated with the throttle axis.

Returns:

The channel for the axis.

getTwist() float[source]

Get the twist value of the current joystick. This depends on the mapping of the joystick connected to the current port.

Returns:

The Twist value of the joystick.

getTwistChannel() int[source]

Get the channel currently associated with the twist axis.

Returns:

The channel for the axis.

getX() float[source]

Get the x position of the HID.

Returns:

the x position

getXChannel() int[source]

Get the channel currently associated with the X axis.

Returns:

The channel for the axis.

getY() float[source]

Get the y position of the HID.

Returns:

the y position

getYChannel() int[source]

Get the channel currently associated with the Y axis.

Returns:

The channel for the axis.

getZ() float[source]

Get the z position of the HID.

Returns:

the z position

getZChannel() int[source]

Get the channel currently associated with the Z axis.

Returns:

The channel for the axis.

setThrottleChannel(channel: int)[source]

Set the channel associated with the throttle axis.

Parameters:

channel – The channel to set the axis to.

setTwistChannel(channel: int)[source]

Set the channel associated with the twist axis.

Parameters:

channel – The channel to set the axis to.

setXChannel(channel: int)[source]

Set the channel associated with the X axis.

Parameters:

channel – The channel to set the axis to.

setYChannel(channel: int)[source]

Set the channel associated with the Y axis.

Parameters:

channel – The channel to set the axis to.

setZChannel(channel: int)[source]

Set the channel associated with the Z axis.

Parameters:

channel – The channel to set the axis to.

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

Constructs an event instance around the top 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 top button’s digital signal attached to the given loop.

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

Constructs an event instance around the trigger 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 trigger button’s digital signal attached to the given loop.