From 3ef73fbe6f22f88334c5eb81b114940d8f4a75cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8D=93?= Date: Thu, 11 Apr 2024 16:45:44 +0800 Subject: [PATCH 1/2] Add device open fail hint and start control when directly run script --- robosuite/devices/spacemouse.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/robosuite/devices/spacemouse.py b/robosuite/devices/spacemouse.py index 604989ff28..7cdf937343 100644 --- a/robosuite/devices/spacemouse.py +++ b/robosuite/devices/spacemouse.py @@ -123,7 +123,15 @@ def __init__( self.vendor_id = vendor_id self.product_id = product_id self.device = hid.device() - self.device.open(self.vendor_id, self.product_id) # SpaceMouse + try: + self.device.open(self.vendor_id, self.product_id) # SpaceMouse + except OSError: + print( + "Failed to open device. " + "Check if the device is connected, the vendor/product id is correct, " + "there are no other processes using the device and rerun with sudo." + ) + raise self.pos_sensitivity = pos_sensitivity self.rot_sensitivity = rot_sensitivity @@ -312,6 +320,7 @@ def control_gripper(self): if __name__ == "__main__": space_mouse = SpaceMouse() + space_mouse.start_control() for i in range(100): print(space_mouse.control, space_mouse.control_gripper) time.sleep(0.02) From dbe9473c2d4fd2b96e69c028eef97bf793e4c3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8D=93?= Date: Thu, 23 May 2024 16:44:10 +0800 Subject: [PATCH 2/2] update vid note --- robosuite/devices/spacemouse.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/robosuite/devices/spacemouse.py b/robosuite/devices/spacemouse.py index 7cdf937343..202cabf18e 100644 --- a/robosuite/devices/spacemouse.py +++ b/robosuite/devices/spacemouse.py @@ -9,7 +9,10 @@ (make sure you run uninstall hid first if it is installed). 3. Make sure SpaceMouse is connected before running the script 4. (Optional) Based on the model of SpaceMouse, you might need to change the - vendor id and product id that correspond to the device. + vendor id and product id that correspond to the device in macros_private. + 5. (Optional) You can also add a udev rule to allow access to the device without sudo. + Create a file named /etc/udev/rules.d/90-my-device.rules with the following content: + SUBSYSTEM=="usb", ATTR{idVendor}=="YOUR_VID_HEX", MODE="0666" For Linux support, you can find open-source Linux drivers and SDKs online. See http://spacenav.sourceforge.net/ @@ -127,9 +130,8 @@ def __init__( self.device.open(self.vendor_id, self.product_id) # SpaceMouse except OSError: print( - "Failed to open device. " - "Check if the device is connected, the vendor/product id is correct, " - "there are no other processes using the device and rerun with sudo." + "Failed to open device. Make sure there are no other " + "processes using the device and rerun with sudo." ) raise @@ -321,6 +323,6 @@ def control_gripper(self): space_mouse = SpaceMouse() space_mouse.start_control() - for i in range(100): + for i in range(1000): print(space_mouse.control, space_mouse.control_gripper) time.sleep(0.02)