From 75195994a1ee9735f45b9627aca314ec46b31810 Mon Sep 17 00:00:00 2001 From: NoahMollerstuen Date: Fri, 9 Feb 2024 15:35:19 -0500 Subject: [PATCH] Better controller mapping Fight me lol --- .../flight_control/manual_control_node.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/surface/flight_control/flight_control/manual_control_node.py b/src/surface/flight_control/flight_control/manual_control_node.py index ce2e4747..fb5dd9e7 100644 --- a/src/surface/flight_control/flight_control/manual_control_node.py +++ b/src/surface/flight_control/flight_control/manual_control_node.py @@ -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 @@ -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