Device#

Devices allow for direct real-time interfacing with the MuJoCo simulation. The current support devices are Keyboard and SpaceMouse.

Base Device#

class robosuite.devices.device.Device(env)#

Base class for all robot controllers. Defines basic interface for all controllers to adhere to. Also contains shared logic for managing multiple and/or multiarmed robots.

abstract start_control()#

Method that should be called externally before controller can start receiving commands.

abstract get_controller_state() Dict#

Returns the current state of the device, a dictionary of pos, orn, grasp, and reset.

Keyboard Device#

class robosuite.devices.keyboard.Keyboard(env, pos_sensitivity=1.0, rot_sensitivity=1.0)#

A minimalistic driver class for a Keyboard. :param env: The environment which contains the robot(s) to control

using this device.

Parameters:
  • pos_sensitivity (float) – Magnitude of input position command scaling

  • rot_sensitivity (float) – Magnitude of scale input rotation commands scaling

get_controller_state()#

Grabs the current state of the keyboard. :returns: A dictionary containing dpos, orn, unmodified orn, grasp, and reset :rtype: dict

on_press(key)#

Key handler for key presses. :param key: key that was pressed :type key: str

on_release(key)#

Key handler for key releases. :param key: key that was pressed :type key: str

static _display_controls()#

Method to pretty print controls.

SpaceMouse Device#

class robosuite.devices.spacemouse.SpaceMouse(env, vendor_id=9583, product_id=50734, pos_sensitivity=1.0, rot_sensitivity=1.0)#

A minimalistic driver class for SpaceMouse with HID library.

Note: Use hid.enumerate() to view all USB human interface devices (HID). Make sure SpaceMouse is detected before running the script. You can look up its vendor/product id from this method.

Parameters:
  • env (RobotEnv) – The environment which contains the robot(s) to control using this device.

  • pos_sensitivity (float) – Magnitude of input position command scaling

  • rot_sensitivity (float) – Magnitude of scale input rotation commands scaling

get_controller_state()#

Grabs the current state of the 3D mouse.

Returns:

A dictionary containing dpos, orn, unmodified orn, grasp, and reset

Return type:

dict

run()#

Listener method that keeps pulling new messages.

property control#

Grabs current pose of Spacemouse

Returns:

6-DoF control value

Return type:

np.array

property control_gripper#

Maps internal states into gripper commands.

Returns:

Whether we’re using single click and hold or not

Return type:

float

static _display_controls()#

Method to pretty print controls.