Commit 2e833cc4 authored by Kelly Guo's avatar Kelly Guo Committed by Kelly Guo

Fixes env wrapper tests timeout and disables importer tests (#181)

# Description

This PR fixes a few of the environment wrapper tests that were
previously hanging on exit, causing timeout failures. In addition, URDF
and MJCF importer tests have been disabled for now until we update the
importer wrappers to support the latest changes in Isaac Sim 4.5.

## Type of change

<!-- As you go through the list, delete the ones that are not
applicable. -->

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


## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.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 updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [ ] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->
parent c76c13f6
...@@ -25,6 +25,7 @@ import ctypes ...@@ -25,6 +25,7 @@ import ctypes
import torch import torch
import unittest import unittest
import carb
import isaacsim.core.utils.prims as prim_utils import isaacsim.core.utils.prims as prim_utils
import omni.isaac.lab.sim as sim_utils import omni.isaac.lab.sim as sim_utils
...@@ -314,6 +315,12 @@ class TestDeformableObject(unittest.TestCase): ...@@ -314,6 +315,12 @@ class TestDeformableObject(unittest.TestCase):
is equal to the applied pose after simulation. We set gravity to zero as we don't want any external is equal to the applied pose after simulation. We set gravity to zero as we don't want any external
forces acting on the object to ensure state remains static. forces acting on the object to ensure state remains static.
""" """
# this flag is necessary to prevent a bug where the simulation gets stuck randomly when running the
# test on many environments.
carb_settings_iface = carb.settings.get_settings()
carb_settings_iface.set_bool("/physics/cooking/ujitsoCollisionCooking", False)
for num_cubes in (1, 2): for num_cubes in (1, 2):
with self.subTest(num_cubes=num_cubes): with self.subTest(num_cubes=num_cubes):
# Turn off gravity for this test as we don't want any external forces acting on the object # Turn off gravity for this test as we don't want any external forces acting on the object
......
...@@ -112,8 +112,8 @@ class TestEnvironments(unittest.TestCase): ...@@ -112,8 +112,8 @@ class TestEnvironments(unittest.TestCase):
# disable control on stop # disable control on stop
env.unwrapped.sim._app_control_on_stop_handle = None # type: ignore env.unwrapped.sim._app_control_on_stop_handle = None # type: ignore
# override action space if set to inf # override action space if set to inf for `Isaac-Lift-Teddy-Bear-Franka-IK-Abs-v0`
if isinstance(env.unwrapped.single_action_space, gym.spaces.Box): if task_name == "Isaac-Lift-Teddy-Bear-Franka-IK-Abs-v0":
for i in range(env.unwrapped.single_action_space.shape[0]): for i in range(env.unwrapped.single_action_space.shape[0]):
if env.unwrapped.single_action_space.low[i] == float("-inf"): if env.unwrapped.single_action_space.low[i] == float("-inf"):
env.unwrapped.single_action_space.low[i] = -1.0 env.unwrapped.single_action_space.low[i] = -1.0
......
...@@ -18,12 +18,13 @@ import gymnasium as gym ...@@ -18,12 +18,13 @@ import gymnasium as gym
import torch import torch
import unittest import unittest
import carb
import omni.usd import omni.usd
from omni.isaac.lab.envs import DirectMARLEnv, multi_agent_to_single_agent from omni.isaac.lab.envs import DirectMARLEnv, multi_agent_to_single_agent
import omni.isaac.lab_tasks # noqa: F401 import omni.isaac.lab_tasks # noqa: F401
from omni.isaac.lab_tasks.utils.parse_cfg import load_cfg_from_registry, parse_env_cfg from omni.isaac.lab_tasks.utils.parse_cfg import parse_env_cfg
from omni.isaac.lab_tasks.utils.wrappers.rl_games import RlGamesVecEnvWrapper from omni.isaac.lab_tasks.utils.wrappers.rl_games import RlGamesVecEnvWrapper
...@@ -41,7 +42,13 @@ class TestRlGamesVecEnvWrapper(unittest.TestCase): ...@@ -41,7 +42,13 @@ class TestRlGamesVecEnvWrapper(unittest.TestCase):
cls.registered_tasks.append(task_spec.id) cls.registered_tasks.append(task_spec.id)
# sort environments by name # sort environments by name
cls.registered_tasks.sort() cls.registered_tasks.sort()
cls.registered_tasks = cls.registered_tasks[:4] cls.registered_tasks = cls.registered_tasks[:5]
# this flag is necessary to prevent a bug where the simulation gets stuck randomly when running the
# test on many environments.
carb_settings_iface = carb.settings.get_settings()
carb_settings_iface.set_bool("/physics/cooking/ujitsoCollisionCooking", False)
# print all existing task names # print all existing task names
print(">>> All registered environments:", cls.registered_tasks) print(">>> All registered environments:", cls.registered_tasks)
...@@ -57,10 +64,11 @@ class TestRlGamesVecEnvWrapper(unittest.TestCase): ...@@ -57,10 +64,11 @@ class TestRlGamesVecEnvWrapper(unittest.TestCase):
print(f">>> Running test for environment: {task_name}") print(f">>> Running test for environment: {task_name}")
# create a new stage # create a new stage
omni.usd.get_context().new_stage() omni.usd.get_context().new_stage()
# reset the rtx sensors carb setting to False
carb.settings.get_settings().set_bool("/isaaclab/render/rtx_sensors", False)
try: try:
# parse configuration # parse configuration
env_cfg = parse_env_cfg(task_name, device=self.device, num_envs=self.num_envs) env_cfg = parse_env_cfg(task_name, device=self.device, num_envs=self.num_envs)
agent_cfg = load_cfg_from_registry(task_name, "rl_games_cfg_entry_point") # noqa: F841
# create environment # create environment
env = gym.make(task_name, cfg=env_cfg) env = gym.make(task_name, cfg=env_cfg)
# convert to single-agent instance if required by the RL algorithm # convert to single-agent instance if required by the RL algorithm
......
...@@ -18,12 +18,13 @@ import gymnasium as gym ...@@ -18,12 +18,13 @@ import gymnasium as gym
import torch import torch
import unittest import unittest
import carb
import omni.usd import omni.usd
from omni.isaac.lab.envs import DirectMARLEnv, multi_agent_to_single_agent from omni.isaac.lab.envs import DirectMARLEnv, multi_agent_to_single_agent
import omni.isaac.lab_tasks # noqa: F401 import omni.isaac.lab_tasks # noqa: F401
from omni.isaac.lab_tasks.utils.parse_cfg import load_cfg_from_registry, parse_env_cfg from omni.isaac.lab_tasks.utils.parse_cfg import parse_env_cfg
from omni.isaac.lab_tasks.utils.wrappers.rsl_rl import RslRlVecEnvWrapper from omni.isaac.lab_tasks.utils.wrappers.rsl_rl import RslRlVecEnvWrapper
...@@ -41,7 +42,13 @@ class TestRslRlVecEnvWrapper(unittest.TestCase): ...@@ -41,7 +42,13 @@ class TestRslRlVecEnvWrapper(unittest.TestCase):
cls.registered_tasks.append(task_spec.id) cls.registered_tasks.append(task_spec.id)
# sort environments by name # sort environments by name
cls.registered_tasks.sort() cls.registered_tasks.sort()
cls.registered_tasks = cls.registered_tasks[:4] cls.registered_tasks = cls.registered_tasks[:5]
# this flag is necessary to prevent a bug where the simulation gets stuck randomly when running the
# test on many environments.
carb_settings_iface = carb.settings.get_settings()
carb_settings_iface.set_bool("/physics/cooking/ujitsoCollisionCooking", False)
# print all existing task names # print all existing task names
print(">>> All registered environments:", cls.registered_tasks) print(">>> All registered environments:", cls.registered_tasks)
...@@ -57,10 +64,11 @@ class TestRslRlVecEnvWrapper(unittest.TestCase): ...@@ -57,10 +64,11 @@ class TestRslRlVecEnvWrapper(unittest.TestCase):
print(f">>> Running test for environment: {task_name}") print(f">>> Running test for environment: {task_name}")
# create a new stage # create a new stage
omni.usd.get_context().new_stage() omni.usd.get_context().new_stage()
# reset the rtx sensors carb setting to False
carb.settings.get_settings().set_bool("/isaaclab/render/rtx_sensors", False)
try: try:
# parse configuration # parse configuration
env_cfg = parse_env_cfg(task_name, device=self.device, num_envs=self.num_envs) env_cfg = parse_env_cfg(task_name, device=self.device, num_envs=self.num_envs)
agent_cfg = load_cfg_from_registry(task_name, "rsl_rl_cfg_entry_point") # noqa: F841
# create environment # create environment
env = gym.make(task_name, cfg=env_cfg) env = gym.make(task_name, cfg=env_cfg)
# convert to single-agent instance if required by the RL algorithm # convert to single-agent instance if required by the RL algorithm
......
...@@ -19,12 +19,13 @@ import numpy as np ...@@ -19,12 +19,13 @@ import numpy as np
import torch import torch
import unittest import unittest
import carb
import omni.usd import omni.usd
from omni.isaac.lab.envs import DirectMARLEnv, multi_agent_to_single_agent from omni.isaac.lab.envs import DirectMARLEnv, multi_agent_to_single_agent
import omni.isaac.lab_tasks # noqa: F401 import omni.isaac.lab_tasks # noqa: F401
from omni.isaac.lab_tasks.utils.parse_cfg import load_cfg_from_registry, parse_env_cfg from omni.isaac.lab_tasks.utils.parse_cfg import parse_env_cfg
from omni.isaac.lab_tasks.utils.wrappers.sb3 import Sb3VecEnvWrapper from omni.isaac.lab_tasks.utils.wrappers.sb3 import Sb3VecEnvWrapper
...@@ -42,7 +43,13 @@ class TestStableBaselines3VecEnvWrapper(unittest.TestCase): ...@@ -42,7 +43,13 @@ class TestStableBaselines3VecEnvWrapper(unittest.TestCase):
cls.registered_tasks.append(task_spec.id) cls.registered_tasks.append(task_spec.id)
# sort environments by name # sort environments by name
cls.registered_tasks.sort() cls.registered_tasks.sort()
cls.registered_tasks = cls.registered_tasks[:4] cls.registered_tasks = cls.registered_tasks[:5]
# this flag is necessary to prevent a bug where the simulation gets stuck randomly when running the
# test on many environments.
carb_settings_iface = carb.settings.get_settings()
carb_settings_iface.set_bool("/physics/cooking/ujitsoCollisionCooking", False)
# print all existing task names # print all existing task names
print(">>> All registered environments:", cls.registered_tasks) print(">>> All registered environments:", cls.registered_tasks)
...@@ -58,10 +65,11 @@ class TestStableBaselines3VecEnvWrapper(unittest.TestCase): ...@@ -58,10 +65,11 @@ class TestStableBaselines3VecEnvWrapper(unittest.TestCase):
print(f">>> Running test for environment: {task_name}") print(f">>> Running test for environment: {task_name}")
# create a new stage # create a new stage
omni.usd.get_context().new_stage() omni.usd.get_context().new_stage()
# reset the rtx sensors carb setting to False
carb.settings.get_settings().set_bool("/isaaclab/render/rtx_sensors", False)
try: try:
# parse configuration # parse configuration
env_cfg = parse_env_cfg(task_name, device=self.device, num_envs=self.num_envs) env_cfg = parse_env_cfg(task_name, device=self.device, num_envs=self.num_envs)
agent_cfg = load_cfg_from_registry(task_name, "sb3_cfg_entry_point") # noqa: F841
# create environment # create environment
env = gym.make(task_name, cfg=env_cfg) env = gym.make(task_name, cfg=env_cfg)
# convert to single-agent instance if required by the RL algorithm # convert to single-agent instance if required by the RL algorithm
......
...@@ -18,12 +18,13 @@ import gymnasium as gym ...@@ -18,12 +18,13 @@ import gymnasium as gym
import torch import torch
import unittest import unittest
import carb
import omni.usd import omni.usd
from omni.isaac.lab.envs import DirectMARLEnv, multi_agent_to_single_agent from omni.isaac.lab.envs import DirectMARLEnv, multi_agent_to_single_agent
import omni.isaac.lab_tasks # noqa: F401 import omni.isaac.lab_tasks # noqa: F401
from omni.isaac.lab_tasks.utils.parse_cfg import load_cfg_from_registry, parse_env_cfg from omni.isaac.lab_tasks.utils.parse_cfg import parse_env_cfg
from omni.isaac.lab_tasks.utils.wrappers.skrl import SkrlVecEnvWrapper from omni.isaac.lab_tasks.utils.wrappers.skrl import SkrlVecEnvWrapper
...@@ -41,7 +42,13 @@ class TestSKRLVecEnvWrapper(unittest.TestCase): ...@@ -41,7 +42,13 @@ class TestSKRLVecEnvWrapper(unittest.TestCase):
cls.registered_tasks.append(task_spec.id) cls.registered_tasks.append(task_spec.id)
# sort environments by name # sort environments by name
cls.registered_tasks.sort() cls.registered_tasks.sort()
cls.registered_tasks = cls.registered_tasks[:4] cls.registered_tasks = cls.registered_tasks[:5]
# this flag is necessary to prevent a bug where the simulation gets stuck randomly when running the
# test on many environments.
carb_settings_iface = carb.settings.get_settings()
carb_settings_iface.set_bool("/physics/cooking/ujitsoCollisionCooking", False)
# print all existing task names # print all existing task names
print(">>> All registered environments:", cls.registered_tasks) print(">>> All registered environments:", cls.registered_tasks)
...@@ -57,10 +64,11 @@ class TestSKRLVecEnvWrapper(unittest.TestCase): ...@@ -57,10 +64,11 @@ class TestSKRLVecEnvWrapper(unittest.TestCase):
print(f">>> Running test for environment: {task_name}") print(f">>> Running test for environment: {task_name}")
# create a new stage # create a new stage
omni.usd.get_context().new_stage() omni.usd.get_context().new_stage()
# reset the rtx sensors carb setting to False
carb.settings.get_settings().set_bool("/isaaclab/render/rtx_sensors", False)
try: try:
# parse configuration # parse configuration
env_cfg = parse_env_cfg(task_name, device=self.device, num_envs=self.num_envs) env_cfg = parse_env_cfg(task_name, device=self.device, num_envs=self.num_envs)
agent_cfg = load_cfg_from_registry(task_name, "skrl_cfg_entry_point") # noqa: F841
# create environment # create environment
env = gym.make(task_name, cfg=env_cfg) env = gym.make(task_name, cfg=env_cfg)
if isinstance(env.unwrapped, DirectMARLEnv): if isinstance(env.unwrapped, DirectMARLEnv):
......
...@@ -11,6 +11,8 @@ TESTS_TO_SKIP = [ ...@@ -11,6 +11,8 @@ TESTS_TO_SKIP = [
"test_env_var_launch.py", # app.close issue "test_env_var_launch.py", # app.close issue
"test_kwarg_launch.py", # app.close issue "test_kwarg_launch.py", # app.close issue
"test_differential_ik.py", # Failing "test_differential_ik.py", # Failing
"test_urdf_converter.py", # need to update wrapper for URDF importer
"test_mjcf_converter.py", # need to update wrapper for MJCF importer
# lab_tasks # lab_tasks
"test_data_collector.py", # Failing "test_data_collector.py", # Failing
"test_record_video.py", # Failing "test_record_video.py", # Failing
......
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