robosuite.devices package#
Submodules#
robosuite.devices.device module#
- class robosuite.devices.device.Device(env)#
Bases:
object
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.
- property active_arm#
- property active_arm_index#
- property base_mode#
- get_arm_action(robot, arm, norm_delta, goal_update_mode='target')#
- abstract get_controller_state() Dict #
Returns the current state of the device, a dictionary of pos, orn, grasp, and reset.
- property grasp#
- input2action(mirror_actions=False) Dict | None #
Converts an input from an active device into a valid action sequence that can be fed into an env.step() call
If a reset is triggered from the device, immediately returns None. Else, returns the appropriate action
- Parameters:
mirror_actions (bool) – actions corresponding to viewing robot from behind. first axis: left/right. second axis: back/forward. third axis: down/up.
- Returns:
- Dictionary of actions to be fed into env.step()
if reset is triggered, returns None
- Return type:
Optional[Dict]
- 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(env, pos_sensitivity=1.0, rot_sensitivity=1.0)#
Bases:
Device
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
- 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
- byte1#
Alias for field number 1
- byte2#
Alias for field number 2
- channel#
Alias for field number 0
- scale#
Alias for field number 3
- class robosuite.devices.spacemouse.SpaceMouse(env, vendor_id=9583, product_id=50734, pos_sensitivity=1.0, rot_sensitivity=1.0)#
Bases:
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:
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
- 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
- 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
- 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