opentau.utils.ros2lerobot

ROS 2 to LeRobot dataset extractors and utilities.

This module provides feature extractors for converting ROS 2 topic messages (e.g., joint_states, images) into LeRobot dataset features. Extractors are keyed by enum value in EXTRACTORS and used by the convert_ros_to_lerobot script.

Functions

get_nested_item(obj, flattened_key[, sep])

Get a nested item from an object using a flattened attribute path.

Classes

ActionExtractor(cfg)

Extracts action (e.g., target joint positions) from ROS 2 control messages.

FeatureExtractor(cfg)

Abstract base class for extracting a dataset feature from a ROS 2 message.

ImageExtractor(cfg)

Extracts observation.image from ROS 2 compressed or raw image messages.

StateExtractor(cfg)

Extracts observation.state from ROS 2 joint_states (position + velocity).

class opentau.utils.ros2lerobot.ActionExtractor(cfg: RosToLeRobotConfig)[source]

Bases: FeatureExtractor

Extracts action (e.g., target joint positions) from ROS 2 control messages.

class opentau.utils.ros2lerobot.FeatureExtractor(cfg: RosToLeRobotConfig)[source]

Bases: ABC

Abstract base class for extracting a dataset feature from a ROS 2 message.

__init__(cfg: RosToLeRobotConfig)[source]

Initialize the extractor with conversion config.

Parameters:

cfg – ROS to LeRobot conversion config (joint order, features, etc.).

class opentau.utils.ros2lerobot.ImageExtractor(cfg: RosToLeRobotConfig)[source]

Bases: FeatureExtractor

Extracts observation.image from ROS 2 compressed or raw image messages.

class opentau.utils.ros2lerobot.StateExtractor(cfg: RosToLeRobotConfig)[source]

Bases: FeatureExtractor

Extracts observation.state from ROS 2 joint_states (position + velocity).

opentau.utils.ros2lerobot.get_nested_item(obj: Any, flattened_key: str, sep: str = '.') Any[source]

Get a nested item from an object using a flattened attribute path.

Parameters:
  • obj – Object with nested attributes to access (e.g., ROS message).

  • flattened_key – Dot-separated path to the attribute (e.g., “a.b.c”).

  • sep – Separator used in the flattened key. Defaults to “.”.

Returns:

The value at the nested path specified by the flattened key.

Example

>>> dct = {"a": {"b": {"c": 42}}}
>>> get_nested_item(dct, "a.b.c")
42