How to use the robosuite.devices.SpaceMouse function in robosuite

To help you get started, we’ve selected a few robosuite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rlworkgroup / metaworld / scripts / mouse_control.py View on Github external
from metaworld.envs.mujoco.sawyer_xyz.sawyer_peg_insertion_side import SawyerPegInsertionSideEnv
from metaworld.envs.mujoco.sawyer_xyz.sawyer_peg_insertion_topdown import SawyerPegInsertionTopdownEnv
from metaworld.envs.mujoco.sawyer_xyz.sawyer_peg_unplug_side import SawyerPegUnplugSideEnv



from robosuite.devices import SpaceMouse
from metaworld.envs.mujoco.utils import rotation
from robosuite.utils.transform_utils import mat2quat
from metaworld.envs.env_util import quat_to_zangle, zangle_to_quat


import gym
import metaworld

space_mouse = SpaceMouse()
env = SawyerPegInsertionTopdownEnv(random_init=True, obs_type='with_goal')
NDIM = env.action_space.low.size
lock_action = False
obs = env.reset()
action = np.zeros(10)
closed = False

while True:
    done = False
    env.render()

    state = space_mouse.get_controller_state()
    dpos, rotation, grasp, reset = (
        state["dpos"],
        state["rotation"],
        state["grasp"],