Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions embodichain/lab/gym/envs/managers/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,23 +416,25 @@ def _modify_feature_names(self, features: dict[str, Any]) -> None:
if feature["shape"] == ():
features[key]["shape"] = (1,)

for functor_name in self._env.observation_manager.active_functors["add"]:
functor_cfg = self._env.observation_manager.get_functor_cfg(
functor_name=functor_name
)
if functor_cfg.func == get_object_uid:
obs_key = functor_cfg.name
asset_uid = functor_cfg.params["entity_cfg"].uid
asset = self._env.sim.get_asset(asset_uid)
if isinstance(asset, RigidObject):
features[obs_key]["names"] = asset_uid
elif isinstance(asset, (Articulation, Robot)):
link_names = asset.link_names
features[obs_key]["names"] = link_names
else:
logger.log_warning(
f"Asset with UID '{asset_uid}' is not RigidObject, Articulation or Robot. Cannot assign feature names based on asset properties."
)
# Add extra observation in `add` mode based on functor config
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline comment says "Add extra observation in add mode", but this block doesn’t add observations; it only updates features[obs_key]["names"] for observations created via add-mode functors. Consider rewording to avoid misleading readers.

Suggested change
# Add extra observation in `add` mode based on functor config
# Update feature names for observations created via `add` mode functors

Copilot uses AI. Check for mistakes.
if "add" in self._env.observation_manager.active_functors:
for functor_name in self._env.observation_manager.active_functors["add"]:
Comment on lines +419 to +421
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change adds a new behavior path when observation_manager.active_functors does not contain an 'add' key, but the existing LeRobotRecorder tests appear to always set active_functors={"add": []} in the mock env. Please add a unit test that exercises _build_features() / _modify_feature_names() with active_functors missing 'add' to prevent regressions of the original KeyError.

Copilot uses AI. Check for mistakes.
functor_cfg = self._env.observation_manager.get_functor_cfg(
functor_name=functor_name
)
if functor_cfg.func == get_object_uid:
obs_key = functor_cfg.name
asset_uid = functor_cfg.params["entity_cfg"].uid
asset = self._env.sim.get_asset(asset_uid)
if isinstance(asset, RigidObject):
features[obs_key]["names"] = asset_uid
elif isinstance(asset, (Articulation, Robot)):
link_names = asset.link_names
features[obs_key]["names"] = link_names
else:
logger.log_warning(
f"Asset with UID '{asset_uid}' is not RigidObject, Articulation or Robot. Cannot assign feature names based on asset properties."
)

def _convert_frame_to_lerobot(
self, obs: TensorDict, action: TensorDict | torch.Tensor, task: str
Expand Down
Loading