Unverified Commit 477cd6b3 authored by David Hoeller's avatar David Hoeller Committed by GitHub

Adds entity clearing in scene for proper environment closing (#380)

# Description

The articulations, objects, and sensors were not cleared properly when
closing the environment. As a result, the invalidation callbacks were
not called, leading to problems if you want to open another environment
right after closing one.

Fixes #342

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have run all the tests with `./orbit.sh --test` and they pass
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
parent c6bdccfa
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.10.18" version = "0.10.19"
# Description # Description
title = "ORBIT framework for Robot Learning" title = "ORBIT framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.10.19 (2024-02-08)
~~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed environment closing so that articulations, objects, and sensors are cleared properly.
0.10.18 (2024-02-05) 0.10.18 (2024-02-05)
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
......
...@@ -173,6 +173,12 @@ class InteractiveScene: ...@@ -173,6 +173,12 @@ class InteractiveScene:
global_paths=self._global_prim_paths, global_paths=self._global_prim_paths,
) )
def __del__(self):
"""Clear instances of registered assets and sensors."""
self.articulations.clear()
self.rigid_objects.clear()
self.sensors.clear()
def __str__(self) -> str: def __str__(self) -> str:
"""Returns a string representation of the scene.""" """Returns a string representation of the scene."""
msg = f"<class {self.__class__.__name__}>\n" msg = f"<class {self.__class__.__name__}>\n"
......
...@@ -53,7 +53,7 @@ def load_cfg_from_registry(task_name: str, entry_point_key: str) -> dict | Any: ...@@ -53,7 +53,7 @@ def load_cfg_from_registry(task_name: str, entry_point_key: str) -> dict | Any:
ValueError: If the entry point key is not available in the gym registry for the task. ValueError: If the entry point key is not available in the gym registry for the task.
""" """
# obtain the configuration entry point # obtain the configuration entry point
cfg_entry_point = gym.spec(task_name).kwargs.pop(entry_point_key) cfg_entry_point = gym.spec(task_name).kwargs.get(entry_point_key)
# check if entry point exists # check if entry point exists
if cfg_entry_point is None: if cfg_entry_point is None:
raise ValueError( raise ValueError(
......
...@@ -62,7 +62,7 @@ class TestEnvironments(unittest.TestCase): ...@@ -62,7 +62,7 @@ class TestEnvironments(unittest.TestCase):
for task_name in self.registered_tasks: for task_name in self.registered_tasks:
print(f">>> Running test for environment: {task_name}") print(f">>> Running test for environment: {task_name}")
# check environment # check environment
self._check_random_actions(task_name, use_gpu, num_envs, num_steps=1000) self._check_random_actions(task_name, use_gpu, num_envs, num_steps=200)
# close the environment # close the environment
print(f">>> Closing environment: {task_name}") print(f">>> Closing environment: {task_name}")
print("-" * 80) print("-" * 80)
...@@ -76,7 +76,7 @@ class TestEnvironments(unittest.TestCase): ...@@ -76,7 +76,7 @@ class TestEnvironments(unittest.TestCase):
for task_name in self.registered_tasks: for task_name in self.registered_tasks:
print(f">>> Running test for environment: {task_name}") print(f">>> Running test for environment: {task_name}")
# check environment # check environment
self._check_random_actions(task_name, use_gpu, num_envs, num_steps=1000) self._check_random_actions(task_name, use_gpu, num_envs, num_steps=200)
# close the environment # close the environment
print(f">>> Closing environment: {task_name}") print(f">>> Closing environment: {task_name}")
print("-" * 80) print("-" * 80)
......
...@@ -13,7 +13,6 @@ TESTS_TO_SKIP = [ ...@@ -13,7 +13,6 @@ TESTS_TO_SKIP = [
"test_differential_ik.py", # Failing "test_differential_ik.py", # Failing
# orbit_tasks # orbit_tasks
"test_data_collector.py", # Failing "test_data_collector.py", # Failing
"test_environments.py", # Failing between 2 environments
"test_record_video.py", # Failing "test_record_video.py", # Failing
"test_rsl_rl_wrapper.py", # Timing out (10 minutes) "test_rsl_rl_wrapper.py", # Timing out (10 minutes)
"test_sb3_wrapper.py", # Timing out (10 minutes) "test_sb3_wrapper.py", # Timing out (10 minutes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment