embodichain.lab#

Submodules

Device Management#

Classes:

Device

Base class for all robot controllers.

DeviceController

Controller that bridges input devices (VR, keyboard, etc.) with robot control.

class embodichain.lab.devices.Device[source]#

Bases: object

Base class for all robot controllers. Defines basic interface for all controllers to adhere to.

Methods:

get_controller_state()

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

start_control()

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

stop_control()

Method that should be called externally to stop the controller.

abstract get_controller_state()[source]#

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

abstract start_control()[source]#

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

abstract stop_control()[source]#

Method that should be called externally to stop the controller.

class embodichain.lab.devices.DeviceController[source]#

Bases: object

Controller that bridges input devices (VR, keyboard, etc.) with robot control.

This controller is agnostic to the environment and can be used in both gym environments and pure simulation contexts. It handles: - Mapping device input to robot joint commands - Joint limit enforcement - Filtering and smoothing (if not handled by device) - Multi-device support

Example

# In gym environment controller = DeviceController(robot=env.robot, device=vr_device) action = controller.get_action() env.step(action)

# In pure simulation controller = DeviceController(robot=sim_robot, device=vr_device) qpos = controller.get_action() sim_robot.set_qpos(qpos)

Methods:

__init__(robot[, device, device_name])

Initialize Device Controller.

add_device(device, device_name[, set_active])

Add a new input device.

get_action([device_name, as_dict])

Get robot action from device input.

get_all_devices()

Get list of all registered device names.

get_device_info([device_name])

Get information about a device.

remove_device(device_name)

Remove a device.

reset()

Reset controller state.

set_active_device(device_name)

Set the active input device.

Attributes:

active_device

Get the currently active device.

__init__(robot, device=None, device_name='default')[source]#

Initialize Device Controller.

Parameters:
  • robot (Robot) – Robot instance to control.

  • device (Optional[Device]) – Input device (VR, keyboard, etc.). Can be None initially.

  • device_name (str) – Name identifier for this device.

property active_device: Device | None#

Get the currently active device.

add_device(device, device_name, set_active=False)[source]#

Add a new input device.

Parameters:
  • device (Device) – Device instance to add.

  • device_name (str) – Name identifier for the device.

  • set_active (bool) – Whether to set this as the active device.

Return type:

None

get_action(device_name=None, as_dict=False)[source]#

Get robot action from device input.

Parameters:
  • device_name (Optional[str]) – Name of device to query. If None, uses active device.

  • as_dict (bool) – Whether to return action as dict (joint_name -> value).

Returns:

[num_envs, num_joints]) or dict, or None if no valid data available.

Return type:

Robot action tensor (shape

get_all_devices()[source]#

Get list of all registered device names.

Return type:

List[str]

get_device_info(device_name=None)[source]#

Get information about a device.

Parameters:

device_name (Optional[str]) – Name of device. If None, uses active device.

Return type:

Dict[str, Any]

Returns:

Device information dict.

remove_device(device_name)[source]#

Remove a device.

Parameters:

device_name (str) – Name of the device to remove.

Return type:

None

reset()[source]#

Reset controller state.

Return type:

None

set_active_device(device_name)[source]#

Set the active input device.

Parameters:

device_name (str) – Name of the device to activate.

Return type:

None