Skip to content

Commit

Permalink
Add OSC_POSITION option in spacemouse input_utils (#209)
Browse files Browse the repository at this point in the history
* Add OSC_POSITION option in spacemouse input_utils
  • Loading branch information
zhuyifengzju authored Apr 29, 2021
1 parent fc3738c commit 95bdb92
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion robosuite/utils/input_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand All @@ -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

0 comments on commit 95bdb92

Please sign in to comment.