From 95bdb9290ecaa883361d91d387d65aee3deadbfd Mon Sep 17 00:00:00 2001 From: YF Date: Wed, 28 Apr 2021 19:27:29 -0500 Subject: [PATCH] Add OSC_POSITION option in spacemouse input_utils (#209) * 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 f0ba5d47bb..b0a4f18492 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 * 1.5 if isinstance(device, Keyboard) else drotation * 50 dpos = dpos * 75 if isinstance(device, Keyboard) else dpos * 125 + elif controller.name == 'OSC_POSITION': + dpos = dpos * 75 if isinstance(device, Keyboard) else dpos * 125 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