-
Notifications
You must be signed in to change notification settings - Fork 857
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes environment closing and tests for task implementations (#231)
# Description This MR fixes the test scripts inside the `omni.isaac.orbit_tasks` extension. The tests were previously crashing since they weren't updated to latest changes in the core framework. Additionally, the tests helped in realizing that the environment did not close properly, i.e. some managers do not get destroyed properly and still hold references to certain scene entities. The MR now explicitly calls all `del` operators over all the managers to delete them in the right-order. ## 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 - [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 --------- Signed-off-by: Mayank Mittal <[email protected]>
- Loading branch information
Showing
15 changed files
with
223 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
source/extensions/omni.isaac.orbit/test/deps/isaacsim/check_app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) 2022-2023, The ORBIT Project Developers. | ||
# All rights reserved. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
""" | ||
This script shows the issue with launching Isaac Sim application in headless mode. | ||
On launching the application in headless mode, the application does not exit gracefully. | ||
There are multiple warnings and errors that are printed on the console. | ||
``` | ||
_isaac_sim/python.sh source/extensions/omni.isaac.orbit/test/deps/isaacsim/check_app.py | ||
``` | ||
Output: | ||
``` | ||
[10.948s] Simulation App Startup Complete | ||
[11.471s] Simulation App Shutting Down | ||
...... [Warning] [carb] [Plugin: omni.spectree.delegate.plugin] Module /media/vulcan/packman-repo/chk/kit-sdk/105.1+release.129498.98d86eae.tc.linux-x86_64.release/exts/omni.usd_resolver/bin/libomni.spectree.delegate.plugin.so remained loaded after unload request | ||
...... [Warning] [omni.core.ITypeFactory] Module /media/vulcan/packman-repo/chk/kit-sdk/105.1+release.129498.98d86eae.tc.linux-x86_64.release/exts/omni.graph.action/bin/libomni.graph.action.plugin.so remained loaded after unload request. | ||
...... [Warning] [omni.core.ITypeFactory] Module /media/vulcan/packman-repo/chk/kit-sdk/105.1+release.129498.98d86eae.tc.linux-x86_64.release/exts/omni.activity.core/bin/libomni.activity.core.plugin.so remained loaded after unload request. | ||
``` | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from omni.isaac.kit import SimulationApp | ||
|
||
if __name__ == "__main__": | ||
app = SimulationApp({"headless": True}) | ||
app.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
source/extensions/omni.isaac.orbit/test/deps/test_scipy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Copyright (c) 2022-2023, The ORBIT Project Developers. | ||
# All rights reserved. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
from __future__ import annotations | ||
|
||
# isort: off | ||
import warnings | ||
|
||
warnings.filterwarnings("ignore", category=DeprecationWarning) | ||
# isort: on | ||
|
||
import numpy as np | ||
import scipy.interpolate as interpolate | ||
import unittest | ||
|
||
|
||
class TestScipyOperations(unittest.TestCase): | ||
"""Tests for assuring scipy related operations used in Orbit.""" | ||
|
||
def test_interpolation(self): | ||
"""Test scipy interpolation 2D method.""" | ||
# parameters | ||
size = (10.0, 10.0) | ||
horizontal_scale = 0.1 | ||
vertical_scale = 0.005 | ||
downsampled_scale = 0.2 | ||
noise_range = (-0.02, 0.1) | ||
noise_step = 0.02 | ||
# switch parameters to discrete units | ||
# -- horizontal scale | ||
width_pixels = int(size[0] / horizontal_scale) | ||
length_pixels = int(size[1] / horizontal_scale) | ||
# -- downsampled scale | ||
width_downsampled = int(size[0] / downsampled_scale) | ||
length_downsampled = int(size[1] / downsampled_scale) | ||
# -- height | ||
height_min = int(noise_range[0] / vertical_scale) | ||
height_max = int(noise_range[1] / vertical_scale) | ||
height_step = int(noise_step / vertical_scale) | ||
|
||
# create range of heights possible | ||
height_range = np.arange(height_min, height_max + height_step, height_step) | ||
# sample heights randomly from the range along a grid | ||
height_field_downsampled = np.random.choice(height_range, size=(width_downsampled, length_downsampled)) | ||
# create interpolation function for the sampled heights | ||
x = np.linspace(0, size[0] * horizontal_scale, width_downsampled) | ||
y = np.linspace(0, size[1] * horizontal_scale, length_downsampled) | ||
|
||
# interpolate the sampled heights to obtain the height field | ||
x_upsampled = np.linspace(0, size[0] * horizontal_scale, width_pixels) | ||
y_upsampled = np.linspace(0, size[1] * horizontal_scale, length_pixels) | ||
# -- method 1: interp2d (this will be deprecated in the future 1.13 release) | ||
func_interp2d = interpolate.interp2d(y, x, height_field_downsampled, kind="cubic") | ||
z_upsampled_interp2d = func_interp2d(y_upsampled, x_upsampled) | ||
# -- method 2: RectBivariateSpline (alternate to interp2d) | ||
func_RectBiVariate = interpolate.RectBivariateSpline(y, x, height_field_downsampled) | ||
z_upsampled_RectBivariant = func_RectBiVariate(y_upsampled, x_upsampled) | ||
# -- method 3: RegularGridInterpolator (recommended from scipy but slow!) | ||
# Ref: https://github.com/scipy/scipy/issues/18010 | ||
func_RegularGridInterpolator = interpolate.RegularGridInterpolator( | ||
(y, x), height_field_downsampled, method="cubic" | ||
) | ||
yy_upsampled, xx_upsampled = np.meshgrid(y_upsampled, x_upsampled, indexing="ij", sparse=True) | ||
z_upsampled_RegularGridInterpolator = func_RegularGridInterpolator((yy_upsampled, xx_upsampled)) | ||
|
||
# check if the interpolated height field is the same as the sampled height field | ||
np.testing.assert_allclose(z_upsampled_interp2d, z_upsampled_RectBivariant, atol=1e-14) | ||
np.testing.assert_allclose(z_upsampled_RectBivariant, z_upsampled_RegularGridInterpolator, atol=1e-14) | ||
np.testing.assert_allclose(z_upsampled_RegularGridInterpolator, z_upsampled_interp2d, atol=1e-14) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.