Skip to content

Commit 1af4806

Browse files
awoll-bdaiexploy-bot
authored andcommitted
Catch AttributeErrors in cleanup (#57)
# Pull Request ### What change is being made Catch `AttributeError`s in cleanup. ### Why this change is being made Avoid error message: ``` Exception ignored in: <function IsaacLabExportableEnvironment.__del__ at 0x7660b13e7240> Traceback (most recent call last): File "/workspace/external/exploy/exploy/exporter/frameworks/isaaclab/env.py", line 65, in __del__ self.cleanup() File "/workspace/external/exploy/exploy/exporter/frameworks/isaaclab/env.py", line 73, in cleanup for i_articulation, articulation in enumerate(self._env.scene.articulations.values()): ^^^^^^^^^^^^^^^ AttributeError: 'ManagerBasedRLEnv' object has no attribute 'scene' ``` ### Tested Confirmed error disappeared. GitOrigin-RevId: 2866e7b9c38de2437d2b753a67ec3a42167646e0
1 parent 63cacaa commit 1af4806

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

  • exploy/exporter/frameworks/isaaclab

exploy/exporter/frameworks/isaaclab/env.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,20 @@ def __del__(self):
4545
self.cleanup()
4646

4747
def cleanup(self):
48-
for i_articulation, articulation in enumerate(self._env.scene.articulations.values()):
49-
articulation._data = self._art_data_list[i_articulation]
50-
51-
for i_rigid_object, rigid_object in enumerate(self._env.scene.rigid_objects.values()):
52-
rigid_object._data = self._rigid_object_list[i_rigid_object]
53-
54-
for sensor_name, original_data in self._raycaster_data_list:
55-
self._env.scene.sensors[sensor_name]._data = original_data
48+
try:
49+
for i_articulation, articulation in enumerate(self._env.scene.articulations.values()):
50+
articulation._data = self._art_data_list[i_articulation]
51+
52+
for i_rigid_object, rigid_object in enumerate(self._env.scene.rigid_objects.values()):
53+
rigid_object._data = self._rigid_object_list[i_rigid_object]
54+
55+
for sensor_name, original_data in self._raycaster_data_list:
56+
self._env.scene.sensors[sensor_name]._data = original_data
57+
except AttributeError:
58+
# In case the environment is already cleaned up by IsaacLab, we might get attribute errors
59+
# when trying to restore the original data sources. We can ignore these errors since the
60+
# environment is being cleaned up anyway.
61+
return
5662

5763
def _get_robots_dict(self) -> dict[str, Any]:
5864
return self._env.scene.articulations

0 commit comments

Comments
 (0)