Skip to content

Commit

Permalink
Reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu Fang committed Nov 15, 2024
1 parent 1aba13a commit 17686f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
11 changes: 2 additions & 9 deletions robosuite/devices/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,10 @@ def input2action(self, mirror_actions=False) -> Optional[Dict]:
ac_dict[f"{active_arm}_abs"] = arm_action["abs"]
ac_dict[f"{active_arm}_delta"] = arm_action["delta"]
# ac_dict[f"{active_arm}_gripper"] = np.array([grasp] * gripper_dof)
ac_dict[f"{active_arm}_gripper"] = [
1,
0.45 * grasp,
grasp,
grasp,
grasp,
grasp
]
ac_dict[f"{active_arm}_gripper"] = [1, 0.45 * grasp, grasp, grasp, grasp, grasp]

# clip actions between -1 and 1
for (k, v) in ac_dict.items():
for k, v in ac_dict.items():
if "abs" not in k:
ac_dict[k] = np.clip(v, -1, 1)

Expand Down
16 changes: 9 additions & 7 deletions robosuite/devices/spacemouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,12 @@ def __init__(

product_id_path_pairs = set()
for device in hid.enumerate():
if device['vendor_id'] == vendor_id:
product_id_path_pairs.add((device['product_id'], device['path']))
if device["vendor_id"] == vendor_id:
product_id_path_pairs.add((device["product_id"], device["path"]))
product_id_path_pairs = sorted(list(product_id_path_pairs))

self.devices = []
for (product_id, path) in product_id_path_pairs:
for product_id, path in product_id_path_pairs:
self.devices.append(SpaceMouseSdkWrapper(product_id, path, pos_sensitivity, rot_sensitivity))

# also add a keyboard for aux controls
Expand Down Expand Up @@ -406,7 +406,7 @@ def input2action(self, mirror_actions=False) -> Optional[Dict]:
original_arm_index = self.active_arm_index
for i in range(len(self.devices)):
ac_dict = super().input2action(mirror_actions)
if ac_dict is None: # reset from any space mouse
if ac_dict is None: # reset from any space mouse
for device in self.devices:
device._reset_state = 1
device._enabled = False
Expand Down Expand Up @@ -467,9 +467,11 @@ def _postprocess_device_outputs(self, dpos, drotation):
space_mice = []
device_pathes = set()
for device in hid.enumerate():
if device['vendor_id'] == vendor_id and device['path'] not in device_pathes:
space_mice.append(SpaceMouseSdkWrapper(device['product_id'], device['path'], pos_sensitivity, rot_sensitivity))
device_pathes.add(device['path'])
if device["vendor_id"] == vendor_id and device["path"] not in device_pathes:
space_mice.append(
SpaceMouseSdkWrapper(device["product_id"], device["path"], pos_sensitivity, rot_sensitivity)
)
device_pathes.add(device["path"])

for space_mouse in space_mice:
space_mouse.start_control()
Expand Down

0 comments on commit 17686f3

Please sign in to comment.