mirror of
https://github.com/SHC-ASTRA/rover-ros2.git
synced 2026-02-11 09:20:40 +00:00
headless collects data for effector controls
This commit is contained in:
@@ -45,8 +45,7 @@ class Headless(Node):
|
|||||||
self.debug_sub = self.create_subscription(String, '/arm/feedback/debug', self.read_feedback, 10)
|
self.debug_sub = self.create_subscription(String, '/arm/feedback/debug', self.read_feedback, 10)
|
||||||
|
|
||||||
|
|
||||||
#self.lastMsg = String() #Used to ignore sending controls repeatedly when they do not change
|
self.laser_status = 0
|
||||||
|
|
||||||
|
|
||||||
# Initialize pygame
|
# Initialize pygame
|
||||||
pygame.init()
|
pygame.init()
|
||||||
@@ -106,23 +105,61 @@ class Headless(Node):
|
|||||||
exit()
|
exit()
|
||||||
input = ArmManual()
|
input = ArmManual()
|
||||||
|
|
||||||
dpad_input = self.gamepad.get_hat(0)
|
|
||||||
input.axis0 = 0
|
|
||||||
if dpad_input[0] == 1:
|
|
||||||
input.axis0 = 1
|
|
||||||
elif dpad_input[0] == -1:
|
|
||||||
input.axis0 = -1
|
|
||||||
|
|
||||||
input.axis1 = -1 * round(self.gamepad.get_axis(0))#left x-axis
|
# Triggers for gripper control
|
||||||
input.axis2 = -1 * round(self.gamepad.get_axis(1))#left y-axis
|
if self.gamepad.get_axis(2) > 0:#left trigger
|
||||||
input.axis3 = -1 * round(self.gamepad.get_axis(4))#right y-axis
|
input.gripper = -1
|
||||||
|
elif self.gamepad.get_axis(5) > 0:#right trigger
|
||||||
|
input.gripper = 1
|
||||||
|
|
||||||
|
# Toggle Laser
|
||||||
|
if self.gamepad.get_button(0):#Start
|
||||||
|
self.laser_status = 1
|
||||||
|
elif self.gamepad.get_button(1):#Back
|
||||||
|
self.laser_status = 0
|
||||||
|
input.laser = self.laser_status
|
||||||
|
|
||||||
|
|
||||||
|
if self.gamepad.get_button(5):#right bumper, control effector
|
||||||
|
|
||||||
|
# Left stick X-axis for effector yaw
|
||||||
|
if self.gamepad.get_axis(0) > 0:
|
||||||
|
input.effeector_yaw = 1
|
||||||
|
elif self.gamepad.get_axis(0) < 0:
|
||||||
|
input.effector_yaw = -1
|
||||||
|
|
||||||
|
# Right stick X-axis for effector roll
|
||||||
|
if self.gamepad.get_axis(3) > 0:
|
||||||
|
input.effector_roll = 1
|
||||||
|
elif self.gamepad.get_axis(3) < 0:
|
||||||
|
input.effector_roll = -1
|
||||||
|
|
||||||
|
else: # Control arm axis
|
||||||
|
dpad_input = self.gamepad.get_hat(0)
|
||||||
|
input.axis0 = 0
|
||||||
|
if dpad_input[0] == 1:
|
||||||
|
input.axis0 = 1
|
||||||
|
elif dpad_input[0] == -1:
|
||||||
|
input.axis0 = -1
|
||||||
|
|
||||||
|
input.axis1 = -1 * round(self.gamepad.get_axis(0))#left x-axis
|
||||||
|
input.axis2 = -1 * round(self.gamepad.get_axis(1))#left y-axis
|
||||||
|
input.axis3 = -1 * round(self.gamepad.get_axis(4))#right y-axis
|
||||||
|
|
||||||
|
|
||||||
|
#Button Mappings
|
||||||
|
#axis2 -> LT
|
||||||
|
#axis5 -> RT
|
||||||
|
#Buttons0 -> A
|
||||||
|
#Buttons1 -> B
|
||||||
|
#Buttons2 -> X
|
||||||
|
#Buttons3 -> Y
|
||||||
|
#Buttons4 -> LB
|
||||||
|
#Buttons5 -> RB
|
||||||
|
#Buttons6 -> Back
|
||||||
|
#Buttons7 -> Start
|
||||||
|
|
||||||
#Temporary, not controlling digit. Awaiting embedded implementation
|
|
||||||
input.effector_yaw = 0
|
|
||||||
input.effector_roll = 0
|
|
||||||
input.gripper = 0
|
|
||||||
input.linear_actuator = 0
|
input.linear_actuator = 0
|
||||||
input.laser = 0
|
|
||||||
|
|
||||||
|
|
||||||
if pygame.joystick.get_count() != 0:
|
if pygame.joystick.get_count() != 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user