Added support for controlling the gripper with the pygame interface of gamepad

Minor modifications in gym_manipulator to quantize the gripper actions
clamped the observations after F.resize in ConvertToLeRobotObservation wrapper due to a bug in F.resize, images were returned exceeding the maximum value of 1.0
This commit is contained in:
Michel Aractingi
2025-03-28 18:12:03 +01:00
committed by AdilZouitine
parent 0150139668
commit 808cf63221
2 changed files with 26 additions and 11 deletions

View File

@@ -258,11 +258,25 @@ class GamepadController(InputController):
elif event.button == 0:
self.episode_end_status = "rerecord_episode"
# RB button (6) for opening gripper
elif event.button == 6:
self.open_gripper_command = True
# LT button (7) for closing gripper
elif event.button == 7:
self.close_gripper_command = True
# Reset episode status on button release
elif event.type == pygame.JOYBUTTONUP:
if event.button in [0, 2, 3]:
self.episode_end_status = None
elif event.button == 6:
self.open_gripper_command = False
elif event.button == 7:
self.close_gripper_command = False
# Check for RB button (typically button 5) for intervention flag
if self.joystick.get_button(5):
self.intervention_flag = True
@@ -298,10 +312,6 @@ class GamepadController(InputController):
logging.error("Error reading gamepad. Is it still connected?")
return 0.0, 0.0, 0.0
def should_intervene(self):
"""Return True if intervention flag was set."""
return self.intervention_flag
class GamepadControllerHID(InputController):
"""Generate motion deltas from gamepad input using HIDAPI."""
@@ -471,10 +481,6 @@ class GamepadControllerHID(InputController):
"""Return True if save button was pressed."""
return self.save_requested
def should_intervene(self):
"""Return True if intervention flag was set."""
return self.intervention_flag
def test_forward_kinematics(robot, fps=10):
logging.info("Testing Forward Kinematics")