robits.core package

Subpackages

Submodules

robits.core.compat module

Module for compatibility

robits.core.config module

class robits.core.config.AudioConfig(audio_backend_name: str, kwargs: Dict[str, ~typing.Any]=<factory>)

Bases: BaseConfig

Configuration class for audio settings.

Parameters:
  • backend – Name of the audio backend

  • kwargs – Additional configuration parameters.

audio_backend_name: str
kwargs: Dict[str, Any]
class robits.core.config.BaseConfig

Bases: ABC

A basic configuration. Additional parameters are stored in a kwargs dictionary.

classmethod from_dict(data: Dict[str, Any]) T

Initializes the class from a Dict

classmethod get_default_parameters() Dict[str, Any]
kwargs: Dict[str, Any]
save_config(config_path) None

Serializes the current state

Parameters:

config_path – the path to serialize to

to_dict() Dict[str, Any]

Converts the class to a dictionary

Returns:

the

to_json() str

Serializes to JSON

Returns:

the JSON string

class robits.core.config.CameraCalibration(camera_name: str, date_updated: str | None = None, extrinsics: ndarray = <factory>, intrinsics: ndarray = <factory>, width: int = 640, height: int = 480, kwargs: Dict[str, ~typing.Any]=<factory>)

Bases: BaseConfig

Configuration class for camera calibration

Parameters:
  • camera_name – Name of the camera

  • date_update – Date when the calibration file has been updated.

  • extrinsics – The camera extrinsics as 4x4 matrix

  • intrinsics – The camera intrinsics as 3x3 matrix

  • width – width of the image size

  • height – height of the image size

  • kwargs – Additional configuration parameters.

camera_name: str
date_updated: str | None = None
extrinsics: ndarray
height: int = 480
intrinsics: ndarray
kwargs: Dict[str, Any]
width: int = 640
class robits.core.config.CameraConfig(camera_name: str, width: int = 640, height: int = 480, hz: int = 30, rgb: bool = True, depth: bool = True, point_cloud: bool = True, kwargs: Dict[str, ~typing.Any]=<factory>)

Bases: BaseConfig

Configuration class for a camera.

Parameters:
  • camera_name – Name of the camera.

  • width – Image width in pixels (default: 640).

  • height – Image height in pixels (default: 480).

  • hz – Frame rate in Hertz (default: 30).

  • rgb – Whether RGB images are enabled (default: True).

  • depth – Whether depth images are enabled (default: True).

  • point_cloud – Whether point cloud data is enabled (default: True).

  • kwargs – Additional configuration parameters.

camera_name: str
depth: bool = True
height: int = 480
hz: int = 30
kwargs: Dict[str, Any]
point_cloud: bool = True
rgb: bool = True
width: int = 640
class robits.core.config.ConfigTypes(value)

Bases: StrEnum

Represents the different config types

audio = 'audio'
camera = 'camera'
camera_calibration = 'calibration'
gripper = 'gripper'
main = 'main'
robot = 'robot'
speech = 'speech'
class robits.core.config.GripperConfig(gripper_name: str, kwargs: Dict[str, ~typing.Any]=<factory>)

Bases: BaseConfig

Configuration class for a gripper.

Parameters:
  • gripper_name – Name of the gripper.

  • kwargs – Additional configuration parameters.

gripper_name: str
kwargs: Dict[str, Any]
class robits.core.config.MainConfig(min_scene_bounds: Sequence[float] | None = <factory>, max_scene_bounds: Sequence[float] | None = <factory>, default_cache_dir: Path = PosixPath('/home/docs/.cache/robits'), kwargs: Dict[str, ~typing.Any]=<factory>)

Bases: BaseConfig

A general configuration file.

default_cache_dir: Path = PosixPath('/home/docs/.cache/robits')
kwargs: Dict[str, Any]
max_scene_bounds: Sequence[float] | None
min_scene_bounds: Sequence[float] | None
class robits.core.config.RobotConfig(robot_name: str, default_joint_positions: Sequence[float] | None = None, joint_names: Sequence[str] | None = None, gripper: Any | None = None, cameras: Sequence[Any] | None = None, transform_robot_to_world: Sequence[Sequence[float]] = <factory>, kwargs: Dict[str, ~typing.Any]=<factory>)

Bases: BaseConfig

Configuration class for a robot.

Parameters:
  • robot_name – Name of the robot.

  • default_joint_positions – The joint positions for the home pose (default: None).

  • joint_names – Names of the joints (default: None).

  • gripper – Gripper configuration (default: None).

  • cameras – List of camera configurations (default: None).

  • transform_robot_to_world – 4x4 matrix of the root in world coordinates

  • kwargs – Additional configuration parameters.

cameras: Sequence[Any] | None = None
default_joint_positions: Sequence[float] | None = None
gripper: Any | None = None
joint_names: Sequence[str] | None = None
kwargs: Dict[str, Any]
robot_name: str
transform_robot_to_world: Sequence[Sequence[float]]
class robits.core.config.SpeechConfig(cache_path: str = '', kwargs: Dict[str, ~typing.Any]=<factory>)

Bases: BaseConfig

Configuration class for speech settings.

Parameters:
  • cache_path – Path to the cache folder

  • kwargs – Additional configuration parameters.

cache_path: str = ''
kwargs: Dict[str, Any]

robits.core.config_manager module

class robits.core.config_manager.ConfigFinder

Bases: ABC

abstractmethod find_config(config_name: str) Path | None

Get the full path of a JSON configuration file. If a config cannot be found, None is returned. :param config_name: Name of the config file (without extension). :return: Path object representing the full path to the JSON config file. None if not found

abstractmethod list() Sequence[str]

Lists available configurations.

Returns:

A list of available configuration names.

abstract property name: str

Name of the config finder

abstract property path: Path

Root path the ConfigFinder operates in

class robits.core.config_manager.ConfigManager

Bases: object

Manages configuration files for different hardware components such as robots, grippers, cameras, audio backends, and speech backends. Provides methods to retrieve configuration paths, load configurations, and list available configurations.

property available_audio_backends: List[str]

Retrieves a list of available audio backend configurations.

Returns:

Available audio backend configuration names.

property available_bimanual_robots: List[str]

Retrieves a list of available bimanual robot configurations.

Returns:

Available bimanual robot configuration names.

property available_camera_calibrations: List[str]

Retrieves a list of available camera calibrations.

Returns:

Available camera calibrations.

property available_cameras: List[str]

Retrieves a list of available camera configurations.

Returns:

Available camera configuration names.

property available_grippers: List[str]

Retrieves a list of available gripper configurations.

Returns:

Available gripper configuration names.

property available_robots: List[str]

Retrieves a list of available robot configurations.

Returns:

Available robot configuration names.

property available_speech_backends: List[str]

Retrieves a list of available speech backend configurations.

Returns:

Available speech backend configuration names.

from_dict(config_type: ConfigTypes, config: Dict[str, Any]) BaseConfig

Converts a dictionary into a configuration object of the appropriate type.

Parameters:
  • config_type – The type of configuration.

  • config – The configuration dictionary.

Returns:

An instance of the appropriate configuration class.

classmethod get() ConfigManager

Retrieves a singleton instance of the ConfigManager.

Returns:

A singleton instance of the class.

get_config_path(config_name: str) Path

Retrieves the file path of a configuration file.

Parameters:

config_name – The name of the configuration.

Returns:

The full path to the configuration file.

get_main_config() MainConfig
get_user_config_dir() Path
Returns:

path where the user configuration is stored.

list(unique=True) List[str]

Lists all available configurations. User configurations can have the same name as system configurations. You can use the unique flag to remove duplicates

Parameters:

unique – Whether duplicated configuration should be filtered.

Returns:

A list of available configuration names.

load_dict(config_name: str) Dict[str, Any]

Loads a configuration file as a dictionary.

Parameters:

config_name – The name of the configuration.

Returns:

The configuration data.

class robits.core.config_manager.PackageResourceFinder(package)

Bases: ConfigFinder

Searches for json configs inside a given package

find_config(config_name: str) Path | None

Get the full path of a JSON configuration file. If a config cannot be found, None is returned. :param config_name: Name of the config file (without extension). :return: Path object representing the full path to the JSON config file. None if not found

list() List[str]

Lists available configurations.

Returns:

A list of available configuration names.

property name: str

Name of the config finder

property path: Path

Root path the ConfigFinder operates in

class robits.core.config_manager.WorkspaceConfigFinder(config_dir)

Bases: ConfigFinder

Searches for configs inside a folder

find_config(config_name: str) Path | None

Get the full path of a JSON configuration file. If a config cannot be found, None is returned. :param config_name: Name of the config file (without extension). :return: Path object representing the full path to the JSON config file. None if not found

list() List[str]

Lists available configurations.

Returns:

A list of available configuration names.

property name: str

Name of the config finder

property path: Path

Root path the ConfigFinder operates in

robits.core.factory module

class robits.core.factory.AudioFactory(config_name)

Bases: BaseFactory

build() AudioBase

Builds an instance

class robits.core.factory.BaseFactory(config_type: ConfigTypes, config_name: str)

Bases: ABC

Base class for common factory logic, including dynamic class instantiation.

abstractmethod build() Any

Builds an instance

build_instance(config_dict: Dict[str, Any]) Any

Dynamically imports and constructs a class instance from a configuration dictionary.

Parameters:
  • config_type – The type of component to build.

  • config_dict – The configuration dictionary.

Returns:

An instance of the specified class.

load_config_dict() Dict[str, Any]

The config to build from

Returns:

the loaded configuration dict

class robits.core.factory.CameraFactory(config_name)

Bases: BaseFactory

build() CameraBase

Builds an instance

class robits.core.factory.GripperFactory(config_name)

Bases: BaseFactory

build() GripperBase

Builds an instance

class robits.core.factory.RobitsFactory(config_type: ConfigTypes, config_name: str)

Bases: BaseFactory

build() UnimanualRobot | BimanualRobot | GripperBase | CameraBase | AudioBase | SpeechBase

Builds an instance

class robits.core.factory.RobotFactory(config_name)

Bases: BaseFactory

build() UnimanualRobot | BimanualRobot

Builds an instance

class robits.core.factory.SpeechFactory(config_name)

Bases: BaseFactory

build() SpeechBase

Builds an instance

robits.core.utils module

class robits.core.utils.CustomDecoder(*args, **kwargs)

Bases: JSONDecoder

class robits.core.utils.FrequencyTimer(frequency)

Bases: object

keeps a loop frequency

reset()

Resets the last cycle

wait_for_cycle()

Waits for the remaining period time. First cycle is skipped if reset() hasn’t been called.

class robits.core.utils.MiscJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: NumpyJSONEncoder

default(obj)

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return super().default(o)
class robits.core.utils.NumpyJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: JSONEncoder

Special json encoder for numpy types. Converts numpy array to a list.

default(obj)

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return super().default(o)
robits.core.utils.check_bounds()