From 55ac0b83e7e01579a3250fe4dc1f044ea3aa3e19 Mon Sep 17 00:00:00 2001 From: Yifeng Zhu Date: Tue, 6 Apr 2021 20:00:34 -0500 Subject: [PATCH 1/2] Add OSC_POSITION option in spacemouse input_utils --- robosuite/utils/input_utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/robosuite/utils/input_utils.py b/robosuite/utils/input_utils.py index 9d0aba0d37..aaa9d42515 100644 --- a/robosuite/utils/input_utils.py +++ b/robosuite/utils/input_utils.py @@ -245,6 +245,8 @@ def input2action(device, robot, active_arm="right", env_configuration=None): # Scale rotation for teleoperation (tuned for OSC) -- gains tuned for each device drotation = drotation * 50 if isinstance(device, SpaceMouse) else drotation * 1.5 dpos = dpos * 125 if isinstance(device, SpaceMouse) else dpos * 75 + elif controller.name== "OSC_POSITION": + dpos = dpos * 125 if isinstance(device, SpaceMouse) else dpos * 75 else: # No other controllers currently supported print("Error: Unsupported controller specified -- Robot must have either an IK or OSC-based controller!") @@ -253,7 +255,10 @@ def input2action(device, robot, active_arm="right", env_configuration=None): grasp = 1 if grasp else -1 # Create action based on action space of individual robot - action = np.concatenate([dpos, drotation, [grasp] * gripper_dof]) + if controller.name == "OSC_POSITION": + action = np.concatenate([dpos, [grasp] * gripper_dof]) + else: + action = np.concatenate([dpos, drotation, [grasp] * gripper_dof]) # Return the action and grasp return action, grasp From de7e83e29ecc2553468b98705c639acb2f7d41d4 Mon Sep 17 00:00:00 2001 From: YF Date: Mon, 19 Apr 2021 22:59:29 -0500 Subject: [PATCH 2/2] coding style improved Add extra space before == to obey coding convention. --- robosuite/utils/input_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/robosuite/utils/input_utils.py b/robosuite/utils/input_utils.py index aaa9d42515..ec3564dee2 100644 --- a/robosuite/utils/input_utils.py +++ b/robosuite/utils/input_utils.py @@ -245,7 +245,7 @@ def input2action(device, robot, active_arm="right", env_configuration=None): # Scale rotation for teleoperation (tuned for OSC) -- gains tuned for each device drotation = drotation * 50 if isinstance(device, SpaceMouse) else drotation * 1.5 dpos = dpos * 125 if isinstance(device, SpaceMouse) else dpos * 75 - elif controller.name== "OSC_POSITION": + elif controller.name == "OSC_POSITION": dpos = dpos * 125 if isinstance(device, SpaceMouse) else dpos * 75 else: # No other controllers currently supported