-
Notifications
You must be signed in to change notification settings - Fork 8
Fix KeyError when 'add' mode not present in observation_manager.active_functors #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| 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
|
||
| 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 | ||
|
|
||
There was a problem hiding this comment.
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
addmode", but this block doesn’t add observations; it only updatesfeatures[obs_key]["names"]for observations created via add-mode functors. Consider rewording to avoid misleading readers.