Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OSC_POSITION option in spacemouse input_utils #209

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 * 50 if isinstance(device, SpaceMouse) else drotation * 1.5
dpos = dpos * 125 if isinstance(device, SpaceMouse) else dpos * 75
elif controller.name== "OSC_POSITION":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the coding convention and add an extra space before ==.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

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!")
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