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.
- 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
- Return type
dict
- on_press(window, key, scancode, action, mods)
Key handler for key presses.
- Parameters
window – [NOT USED]
key (int) – keycode corresponding to the key that was pressed
scancode – [NOT USED]
action – [NOT USED]
mods – [NOT USED]
- on_release(window, key, scancode, action, mods)
Key handler for key releases.
- Parameters
window – [NOT USED]
key (int) – keycode corresponding to the key that was pressed
scancode – [NOT USED]
action – [NOT USED]
mods – [NOT USED]
- 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.