robosuite.devices package
Submodules
robosuite.devices.device module
- class robosuite.devices.device.Device
Bases:
object
Base class for all robot controllers. Defines basic interface for all controllers to adhere to.
- abstract get_controller_state()
Returns the current state of the device, a dictionary of pos, orn, grasp, and reset.
- abstract start_control()
Method that should be called externally before controller can start receiving commands.
robosuite.devices.keyboard module
Driver class for Keyboard controller.
- class robosuite.devices.keyboard.Keyboard(pos_sensitivity=1.0, rot_sensitivity=1.0)
Bases:
robosuite.devices.device.Device
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]
- start_control()
Method that should be called externally before controller can start receiving commands.
robosuite.devices.spacemouse module
Driver class for SpaceMouse controller.
This class provides a driver support to SpaceMouse on macOS. In particular, we assume you are using a SpaceMouse Wireless by default.
- To set up a new SpaceMouse controller:
Download and install driver from https://www.3dconnexion.com/service/drivers.html
Install hidapi library through pip (make sure you run uninstall hid first if it is installed).
Make sure SpaceMouse is connected before running the script
(Optional) Based on the model of SpaceMouse, you might need to change the vendor id and product id that correspond to the device.
- For Linux support, you can find open-source Linux drivers and SDKs online.
- class robosuite.devices.spacemouse.AxisSpec(channel, byte1, byte2, scale)
Bases:
tuple
- property byte1
Alias for field number 1
- property byte2
Alias for field number 2
- property channel
Alias for field number 0
- property scale
Alias for field number 3
- class robosuite.devices.spacemouse.SpaceMouse(vendor_id=9583, product_id=50735, pos_sensitivity=1.0, rot_sensitivity=1.0)
Bases:
robosuite.devices.device.Device
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
- 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
- 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.
- start_control()
Method that should be called externally before controller can start receiving commands.
- robosuite.devices.spacemouse.convert(b1, b2)
Converts SpaceMouse message to commands.
- Parameters
b1 (int) – 8-bit byte
b2 (int) – 8-bit byte
- Returns
Scaled value from Spacemouse message
- Return type
float
- robosuite.devices.spacemouse.scale_to_control(x, axis_scale=350.0, min_v=- 1.0, max_v=1.0)
Normalize raw HID readings to target range.
- Parameters
x (int) – Raw reading from HID
axis_scale (float) – (Inverted) scaling factor for mapping raw input value
min_v (float) – Minimum limit after scaling
max_v (float) – Maximum limit after scaling
- Returns
Clipped, scaled input from HID
- Return type
float
- robosuite.devices.spacemouse.to_int16(y1, y2)
Convert two 8 bit bytes to a signed 16 bit integer.
- Parameters
y1 (int) – 8-bit byte
y2 (int) – 8-bit byte
- Returns
16-bit integer
- Return type
int