in gym_hil/wrappers/intervention_utils.py [0:0]
def start(self):
"""Initialize pygame and the gamepad."""
import pygame
pygame.init()
pygame.joystick.init()
if pygame.joystick.get_count() == 0:
print("No gamepad detected. Please connect a gamepad and try again.")
self.running = False
return
self.joystick = pygame.joystick.Joystick(0)
self.joystick.init()
joystick_name = self.joystick.get_name()
print(f"Initialized gamepad: {joystick_name}")
# Load controller configuration based on joystick name
self.controller_config = load_controller_config(joystick_name, self.config_path)
# Get button mappings from config
buttons = self.controller_config.get("buttons", {})
print("Gamepad controls:")
print(f" {buttons.get('rb', 'RB')} button: Intervention")
print(" Left analog stick: Move in X-Y plane")
print(" Right analog stick (vertical): Move in Z axis")
print(f" {buttons.get('lt', 'LT')} button: Close gripper")
print(f" {buttons.get('rt', 'RT')} button: Open gripper")
print(f" {buttons.get('b', 'B')}/Circle button: Exit")
print(f" {buttons.get('y', 'Y')}/Triangle button: End episode with SUCCESS")
print(f" {buttons.get('a', 'A')}/Cross button: End episode with FAILURE")
print(f" {buttons.get('x', 'X')}/Square button: Rerecord episode")