Device
Contents
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#
Base class for all robot controllers. Defines basic interface for all controllers to adhere to.
- abstract start_control()#
Method that should be called externally before controller can start receiving commands.
- abstract get_controller_state()#
Returns the current state of the device, a dictionary of pos, orn, grasp, and reset.
Keyboard Device#
- class robosuite.devices.keyboard.Keyboard(pos_sensitivity=1.0, rot_sensitivity=1.0)#
A minimalistic driver class for a Keyboard. :param pos_sensitivity: Magnitude of input position command scaling :type pos_sensitivity: float :param rot_sensitivity: Magnitude of scale input rotation commands scaling :type rot_sensitivity: float
- 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(vendor_id=9583, product_id=50735, 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
vendor_id (int) – HID device vendor id
product_id (int) – HID device product id
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.