in gym_hil/wrappers/intervention_utils.py [0:0]
def update(self):
"""Process pygame events to get fresh gamepad readings."""
import pygame
# Get button mappings from config
buttons = self.controller_config.get("buttons", {})
y_button = buttons.get("y", 3) # Default to 3 if not found
a_button = buttons.get("a", 0) # Default to 0 if not found (Logitech F310)
x_button = buttons.get("x", 2) # Default to 2 if not found (Logitech F310)
lt_button = buttons.get("lt", 6) # Default to 6 if not found
rt_button = buttons.get("rt", 7) # Default to 7 if not found
rb_button = buttons.get("rb", 5) # Default to 5 if not found
for event in pygame.event.get():
if event.type == pygame.JOYBUTTONDOWN:
if event.button == y_button:
self.episode_end_status = "success"
elif event.button == a_button:
self.episode_end_status = "failure"
elif event.button == x_button:
self.episode_end_status = "rerecord_episode"
elif event.button == lt_button:
self.close_gripper_command = True
elif event.button == rt_button:
self.open_gripper_command = True
# Reset episode status on button release
elif event.type == pygame.JOYBUTTONUP:
if event.button in [x_button, a_button, y_button]:
self.episode_end_status = None
elif event.button == lt_button:
self.close_gripper_command = False
elif event.button == rt_button:
self.open_gripper_command = False
# Check for RB button for intervention flag
if self.joystick.get_button(rb_button):
self.intervention_flag = True
else:
self.intervention_flag = False