Skip to content

Commit

Permalink
Better controller mapping
Browse files Browse the repository at this point in the history
Fight me lol
  • Loading branch information
NoahMollerstuen committed Feb 9, 2024
1 parent 561decc commit 7519599
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/surface/flight_control/flight_control/manual_control_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
# Joystick Directions 1 is up/left -1 is down/right
# X is forward/backward Y is left/right
# L2 and R2 1 is not pressed and -1 is pressed
LJOYY: int = 0
LJOYX: int = 1
LJOYX: int = 0
LJOYY: int = 1
L2PRESS_PERCENT: int = 2
RJOYY: int = 3
RJOYX: int = 4
RJOYX: int = 3
RJOYY: int = 4
R2PRESS_PERCENT: int = 5
DPADHOR: int = 6
DPADVERT: int = 7
Expand Down Expand Up @@ -91,12 +91,12 @@ def joystick_to_pixhawk(self, msg: Joy) -> None:
buttons: MutableSequence[int] = msg.buttons

instruction = PixhawkInstruction(
pitch=axes[DPADVERT], # DPad
forward=axes[LJOYY], # Left Joystick Y
lateral=-axes[LJOYX], # Left Joystick X
vertical=(axes[L2PRESS_PERCENT] - axes[R2PRESS_PERCENT]) / 2, # L2/R2 triggers
roll=buttons[R1] - buttons[L1], # L1/R1 buttons
vertical=axes[RJOYX], # Right Joystick Z
forward=axes[LJOYX], # Left Joystick X
lateral=-axes[LJOYY], # Left Joystick Y
yaw=(axes[R2PRESS_PERCENT] - axes[L2PRESS_PERCENT]) / 2 # L2/R2 buttons
pitch=-axes[DPADVERT], # DPad
yaw=-axes[RJOYX], # Right Joystick X
)

# Smooth out adjustments
Expand Down

0 comments on commit 7519599

Please sign in to comment.