in gym_hil/wrappers/intervention_utils.py [0:0]
def start(self):
"""Connect to the gamepad using HIDAPI."""
import hid
self.device_info = self.find_device()
if not self.device_info:
self.running = False
return
try:
print(f"Connecting to gamepad at path: {self.device_info['path']}")
self.device = hid.device()
self.device.open_path(self.device_info["path"])
self.device.set_nonblocking(1)
manufacturer = self.device.get_manufacturer_string()
product = self.device.get_product_string()
print(f"Connected to {manufacturer} {product}")
print("Gamepad controls (HID mode):")
print(" Left analog stick: Move in X-Y plane")
print(" Right analog stick: Move in Z axis (vertical)")
print(" Button 1/B/Circle: Exit")
print(" Button 2/A/Cross: End episode with SUCCESS")
print(" Button 3/X/Square: End episode with FAILURE")
except OSError as e:
print(f"Error opening gamepad: {e}")
print("You might need to run this with sudo/admin privileges on some systems")
self.running = False