diff --git a/commands2/button/commandjoystick.py b/commands2/button/commandjoystick.py index 909fb00..0b43d8d 100644 --- a/commands2/button/commandjoystick.py +++ b/commands2/button/commandjoystick.py @@ -146,6 +146,9 @@ def getX(self) -> float: """ Get the x position of the HID. + This depends on the mapping of the joystick connected to the current port. On most + joysticks, positive is to the right. + :returns: the x position """ return self._hid.getX() @@ -154,6 +157,9 @@ def getY(self) -> float: """ Get the y position of the HID. + This depends on the mapping of the joystick connected to the current port. On most + joysticks, positive is to the back. + :returns: the y position """ return self._hid.getY() @@ -186,8 +192,8 @@ def getThrottle(self) -> float: def getMagnitude(self) -> float: """ - Get the magnitude of the direction vector formed by the joystick's current position relative to - its origin. + Get the magnitude of the vector formed by the joystick's current position relative to its + origin. :returns: The magnitude of the direction vector """ @@ -195,15 +201,25 @@ def getMagnitude(self) -> float: def getDirectionRadians(self) -> float: """ - Get the direction of the vector formed by the joystick and its origin in radians. + Get the direction of the vector formed by the joystick and its origin in radians. 0 is forward + and clockwise is positive. (Straight right is π/2.) :returns: The direction of the vector in radians """ + # https://docs.wpilib.org/en/stable/docs/software/basic-programming/coordinate-system.html#joystick-and-controller-coordinate-system + # A positive rotation around the X axis moves the joystick right, and a + # positive rotation around the Y axis moves the joystick backward. When + # treating them as translations, 0 radians is measured from the right + # direction, and angle increases clockwise. + # + # It's rotated 90 degrees CCW (y is negated and the arguments are reversed) + # so that 0 radians is forward. return self._hid.getDirectionRadians() def getDirectionDegrees(self) -> float: """ - Get the direction of the vector formed by the joystick and its origin in degrees. + Get the direction of the vector formed by the joystick and its origin in degrees. 0 is forward + and clockwise is positive. (Straight right is 90.) :returns: The direction of the vector in degrees """ diff --git a/commands2/button/commandps4controller.py b/commands2/button/commandps4controller.py index 562839f..8703ef8 100644 --- a/commands2/button/commandps4controller.py +++ b/commands2/button/commandps4controller.py @@ -231,7 +231,7 @@ def touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: def getLeftX(self) -> float: """ - Get the X axis value of left side of the controller. + Get the X axis value of left side of the controller. Right is positive. :returns: the axis value. """ @@ -239,7 +239,7 @@ def getLeftX(self) -> float: def getRightX(self) -> float: """ - Get the X axis value of right side of the controller. + Get the X axis value of right side of the controller. Right is positive. :returns: the axis value. """ @@ -247,7 +247,7 @@ def getRightX(self) -> float: def getLeftY(self) -> float: """ - Get the Y axis value of left side of the controller. + Get the Y axis value of left side of the controller. Back is positive. :returns: the axis value. """ @@ -255,7 +255,7 @@ def getLeftY(self) -> float: def getRightY(self) -> float: """ - Get the Y axis value of right side of the controller. + Get the Y axis value of right side of the controller. Back is positive. :returns: the axis value. """ diff --git a/commands2/button/commandxboxcontroller.py b/commands2/button/commandxboxcontroller.py index 5488081..926883c 100644 --- a/commands2/button/commandxboxcontroller.py +++ b/commands2/button/commandxboxcontroller.py @@ -213,7 +213,7 @@ def rightTrigger( def getLeftX(self) -> float: """ - Get the X axis value of left side of the controller. + Get the X axis value of left side of the controller. Right is positive. :returns: The axis value. """ @@ -221,7 +221,7 @@ def getLeftX(self) -> float: def getRightX(self) -> float: """ - Get the X axis value of right side of the controller. + Get the X axis value of right side of the controller. Right is positive. :returns: The axis value. """ @@ -229,7 +229,7 @@ def getRightX(self) -> float: def getLeftY(self) -> float: """ - Get the Y axis value of left side of the controller. + Get the Y axis value of left side of the controller. Back is positive. :returns: The axis value. """ @@ -237,7 +237,7 @@ def getLeftY(self) -> float: def getRightY(self) -> float: """ - Get the Y axis value of right side of the controller. + Get the Y axis value of right side of the controller. Back is positive. :returns: The axis value. """