Skip to content

Commit 092edf9

Browse files
committed
Improve HID direction documentation
1 parent 23a4f87 commit 092edf9

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

commands2/button/commandjoystick.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ def getX(self) -> float:
146146
"""
147147
Get the x position of the HID.
148148
149+
This depends on the mapping of the joystick connected to the current port. On most
150+
joysticks, positive is to the right.
151+
149152
:returns: the x position
150153
"""
151154
return self._hid.getX()
@@ -154,6 +157,9 @@ def getY(self) -> float:
154157
"""
155158
Get the y position of the HID.
156159
160+
This depends on the mapping of the joystick connected to the current port. On most
161+
joysticks, positive is to the back.
162+
157163
:returns: the y position
158164
"""
159165
return self._hid.getY()
@@ -186,24 +192,29 @@ def getThrottle(self) -> float:
186192

187193
def getMagnitude(self) -> float:
188194
"""
189-
Get the magnitude of the direction vector formed by the joystick's current position relative to
190-
its origin.
195+
Get the magnitude of the vector formed by the joystick's current position relative to its
196+
origin.
191197
192198
:returns: The magnitude of the direction vector
193199
"""
194200
return self._hid.getMagnitude()
195201

196202
def getDirectionRadians(self) -> float:
197203
"""
198-
Get the direction of the vector formed by the joystick and its origin in radians.
204+
Get the direction of the vector formed by the joystick and its origin in radians. 0 is forward
205+
and clockwise is positive. (Straight right is π/2.)
199206
200207
:returns: The direction of the vector in radians
201208
"""
209+
# https://docs.wpilib.org/en/stable/docs/software/basic-programming/coordinate-system.html#joystick-and-controller-coordinate-system
210+
# +X is right and +Y is back, so 0 radians is right and CW is positive. Rotate by 90 degrees
211+
# CCW to make 0 radians forward and CW positive.
202212
return self._hid.getDirectionRadians()
203213

204214
def getDirectionDegrees(self) -> float:
205215
"""
206-
Get the direction of the vector formed by the joystick and its origin in degrees.
216+
Get the direction of the vector formed by the joystick and its origin in degrees. 0 is forward
217+
and clockwise is positive. (Straight right is 90.)
207218
208219
:returns: The direction of the vector in degrees
209220
"""

commands2/button/commandps4controller.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,31 +231,31 @@ def touchpad(self, loop: Optional[EventLoop] = None) -> Trigger:
231231

232232
def getLeftX(self) -> float:
233233
"""
234-
Get the X axis value of left side of the controller.
234+
Get the X axis value of left side of the controller. Right is positive.
235235
236236
:returns: the axis value.
237237
"""
238238
return self._hid.getLeftX()
239239

240240
def getRightX(self) -> float:
241241
"""
242-
Get the X axis value of right side of the controller.
242+
Get the X axis value of right side of the controller. Right is positive.
243243
244244
:returns: the axis value.
245245
"""
246246
return self._hid.getRightX()
247247

248248
def getLeftY(self) -> float:
249249
"""
250-
Get the Y axis value of left side of the controller.
250+
Get the Y axis value of left side of the controller. Back is positive.
251251
252252
:returns: the axis value.
253253
"""
254254
return self._hid.getLeftY()
255255

256256
def getRightY(self) -> float:
257257
"""
258-
Get the Y axis value of right side of the controller.
258+
Get the Y axis value of right side of the controller. Back is positive.
259259
260260
:returns: the axis value.
261261
"""

commands2/button/commandxboxcontroller.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,31 +213,31 @@ def rightTrigger(
213213

214214
def getLeftX(self) -> float:
215215
"""
216-
Get the X axis value of left side of the controller.
216+
Get the X axis value of left side of the controller. Right is positive.
217217
218218
:returns: The axis value.
219219
"""
220220
return self._hid.getLeftX()
221221

222222
def getRightX(self) -> float:
223223
"""
224-
Get the X axis value of right side of the controller.
224+
Get the X axis value of right side of the controller. Right is positive.
225225
226226
:returns: The axis value.
227227
"""
228228
return self._hid.getRightX()
229229

230230
def getLeftY(self) -> float:
231231
"""
232-
Get the Y axis value of left side of the controller.
232+
Get the Y axis value of left side of the controller. Back is positive.
233233
234234
:returns: The axis value.
235235
"""
236236
return self._hid.getLeftY()
237237

238238
def getRightY(self) -> float:
239239
"""
240-
Get the Y axis value of right side of the controller.
240+
Get the Y axis value of right side of the controller. Back is positive.
241241
242242
:returns: The axis value.
243243
"""

0 commit comments

Comments
 (0)