Unverified Commit 6184b562 authored by James Tigue's avatar James Tigue Committed by GitHub

Fixes articulation and render_cfg tests to be proper pytests (#2851)

# Description

Fixes some pytest migration errors for test_articulation and
test_render_cfg

Fixes # (issue)

## 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
- [ ] 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
-->

---------
Signed-off-by: 's avatarKelly Guo <kellyg@nvidia.com>
Signed-off-by: 's avatarKelly Guo <kellyguo123@hotmail.com>
Co-authored-by: 's avatarKelly Guo <kellyg@nvidia.com>
Co-authored-by: 's avatarKelly Guo <kellyguo123@hotmail.com>
parent 043f045c
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.40.12" version = "0.40.13"
# Description # Description
title = "Isaac Lab framework for Robot Learning" title = "Isaac Lab framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.40.13 (2025-07-03)
~~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed unittest tests that are floating inside pytests for articulation and rendering
0.40.12 (2025-07-03) 0.40.12 (2025-07-03)
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
......
...@@ -1572,40 +1572,42 @@ def test_body_incoming_joint_wrench_b_single_joint(sim, num_articulations, devic ...@@ -1572,40 +1572,42 @@ def test_body_incoming_joint_wrench_b_single_joint(sim, num_articulations, devic
rtol=1e-3, rtol=1e-3,
) )
def test_setting_articulation_root_prim_path(self):
"""Test that the articulation root prim path can be set explicitly.""" @pytest.mark.parametrize("device", ["cuda:0", "cpu"])
with build_simulation_context(device="cuda:0", add_ground_plane=False, auto_add_lighting=True) as sim: def test_setting_articulation_root_prim_path(sim, device):
sim._app_control_on_stop_handle = None """Test that the articulation root prim path can be set explicitly."""
# Create articulation sim._app_control_on_stop_handle = None
articulation_cfg = generate_articulation_cfg(articulation_type="humanoid") # Create articulation
print(articulation_cfg.spawn.usd_path) articulation_cfg = generate_articulation_cfg(articulation_type="humanoid")
articulation_cfg.articulation_root_prim_path = "/torso" print(articulation_cfg.spawn.usd_path)
articulation, _ = generate_articulation(articulation_cfg, 1, "cuda:0") articulation_cfg.articulation_root_prim_path = "/torso"
articulation, _ = generate_articulation(articulation_cfg, 1, device)
# Check that boundedness of articulation is correct
self.assertEqual(ctypes.c_long.from_address(id(articulation)).value, 1) # Check that boundedness of articulation is correct
assert ctypes.c_long.from_address(id(articulation)).value == 1
# Play sim
sim.reset() # Play sim
# Check if articulation is initialized sim.reset()
self.assertTrue(articulation._is_initialized) # Check if articulation is initialized
assert articulation._is_initialized
def test_setting_invalid_articulation_root_prim_path(self):
"""Test that the articulation root prim path can be set explicitly."""
with build_simulation_context(device="cuda:0", add_ground_plane=False, auto_add_lighting=True) as sim: @pytest.mark.parametrize("device", ["cuda:0", "cpu"])
sim._app_control_on_stop_handle = None def test_setting_invalid_articulation_root_prim_path(sim, device):
# Create articulation """Test that the articulation root prim path can be set explicitly."""
articulation_cfg = generate_articulation_cfg(articulation_type="humanoid") sim._app_control_on_stop_handle = None
print(articulation_cfg.spawn.usd_path) # Create articulation
articulation_cfg.articulation_root_prim_path = "/non_existing_prim_path" articulation_cfg = generate_articulation_cfg(articulation_type="humanoid")
articulation, _ = generate_articulation(articulation_cfg, 1, "cuda:0") print(articulation_cfg.spawn.usd_path)
articulation_cfg.articulation_root_prim_path = "/non_existing_prim_path"
# Check that boundedness of articulation is correct articulation, _ = generate_articulation(articulation_cfg, 1, device=device)
self.assertEqual(ctypes.c_long.from_address(id(articulation)).value, 1)
# Check that boundedness of articulation is correct
# Play sim assert ctypes.c_long.from_address(id(articulation)).value == 1
with pytest.raises(RuntimeError):
sim.reset() # Play sim
with pytest.raises(RuntimeError):
sim.reset()
@pytest.mark.parametrize("num_articulations", [1, 2]) @pytest.mark.parametrize("num_articulations", [1, 2])
......
...@@ -89,50 +89,51 @@ def test_render_cfg(): ...@@ -89,50 +89,51 @@ def test_render_cfg():
assert carb_settings_iface.get("/rtx/ambientOcclusion/enabled") == sim.cfg.render.enable_ambient_occlusion assert carb_settings_iface.get("/rtx/ambientOcclusion/enabled") == sim.cfg.render.enable_ambient_occlusion
assert carb_settings_iface.get("/rtx/post/aa/op") == 4 # dlss = 3, dlaa=4 assert carb_settings_iface.get("/rtx/post/aa/op") == 4 # dlss = 3, dlaa=4
def test_render_cfg_presets(self):
"""Test that the simulation context is created with the correct render cfg preset with overrides.""" def test_render_cfg_presets():
"""Test that the simulation context is created with the correct render cfg preset with overrides."""
# carb setting dictionary overrides
carb_settings = {"/rtx/raytracing/subpixel/mode": 3, "/rtx/pathtracing/maxSamplesPerLaunch": 999999} # carb setting dictionary overrides
# user-friendly setting overrides carb_settings = {"/rtx/raytracing/subpixel/mode": 3, "/rtx/pathtracing/maxSamplesPerLaunch": 999999}
dlss_mode = ("/rtx/post/dlss/execMode", 5) # user-friendly setting overrides
dlss_mode = ("/rtx/post/dlss/execMode", 5)
rendering_modes = ["performance", "balanced", "quality", "xr"]
rendering_modes = ["performance", "balanced", "quality", "xr"]
for rendering_mode in rendering_modes:
# grab groundtruth preset settings for rendering_mode in rendering_modes:
preset_filename = f"apps/rendering_modes/{rendering_mode}.kit" # grab groundtruth preset settings
with open(preset_filename) as file: preset_filename = f"apps/rendering_modes/{rendering_mode}.kit"
preset_dict = toml.load(file) with open(preset_filename) as file:
preset_dict = dict(flatdict.FlatDict(preset_dict, delimiter=".")) preset_dict = toml.load(file)
preset_dict = dict(flatdict.FlatDict(preset_dict, delimiter="."))
render_cfg = RenderCfg(
rendering_mode=rendering_mode, render_cfg = RenderCfg(
dlss_mode=dlss_mode[1], rendering_mode=rendering_mode,
carb_settings=carb_settings, dlss_mode=dlss_mode[1],
) carb_settings=carb_settings,
)
cfg = SimulationCfg(render=render_cfg)
cfg = SimulationCfg(render=render_cfg)
SimulationContext(cfg)
SimulationContext(cfg)
carb_settings_iface = carb.settings.get_settings()
for key, val in preset_dict.items(): carb_settings_iface = carb.settings.get_settings()
setting_name = "/" + key.replace(".", "/") # convert to carb setting format for key, val in preset_dict.items():
setting_name = "/" + key.replace(".", "/") # convert to carb setting format
if setting_name in carb_settings:
# grab groundtruth from carb setting dictionary overrides if setting_name in carb_settings:
setting_gt = carb_settings[setting_name] # grab groundtruth from carb setting dictionary overrides
elif setting_name == dlss_mode[0]: setting_gt = carb_settings[setting_name]
# grab groundtruth from user-friendly setting overrides elif setting_name == dlss_mode[0]:
setting_gt = dlss_mode[1] # grab groundtruth from user-friendly setting overrides
else: setting_gt = dlss_mode[1]
# grab groundtruth from preset else:
setting_gt = val # grab groundtruth from preset
setting_gt = val
setting_val = get_carb_setting(carb_settings_iface, setting_name)
setting_val = get_carb_setting(carb_settings_iface, setting_name)
self.assertEqual(setting_gt, setting_val)
assert setting_gt == setting_val
@pytest.mark.skip(reason="Timeline not stopped") @pytest.mark.skip(reason="Timeline not stopped")
......
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