Skip to content

Commit cace5c5

Browse files
authored
Fixes minor bugs in RayCasterCamera and BaseEnvWindow (#1308)
# Description * Fixes a bug in RayCasterCamera's print function that was accessing `RayCaster.meshes` instead of `self.meshes` * Fixes a bug in BaseEnvWindow that was trying to access attributes from undefined configs when building UI elements for action and command terms ## 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 `./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 - [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
1 parent 1e3b6ec commit cace5c5

File tree

11 files changed

+211
-24
lines changed

11 files changed

+211
-24
lines changed

source/extensions/omni.isaac.lab/config/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
# Note: Semantic Versioning is used: https://semver.org/
4-
version = "0.27.5"
4+
version = "0.27.6"
55

66
# Description
77
title = "Isaac Lab framework for Robot Learning"

source/extensions/omni.isaac.lab/docs/CHANGELOG.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changelog
22
---------
33

4+
0.27.6 (2024-10-25)
5+
~~~~~~~~~~~~~~~~~~~
6+
7+
Fixed
8+
^^^^^
9+
10+
* Fixed usage of ``meshes`` property in :class:`omni.isaac.lab.sensors.RayCasterCamera` to use ``self.meshes`` instead of the undefined ``RayCaster.meshes``.
11+
* Fixed issue in :class:`omni.isaac.lab.envs.ui.BaseEnvWindow` where undefined configs were being accessed when creating debug visualization elements in UI.
12+
13+
414
0.27.5 (2024-10-25)
515
~~~~~~~~~~~~~~~~~~~
616

source/extensions/omni.isaac.lab/omni/isaac/lab/envs/ui/base_env_window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def _create_debug_vis_ui_element(self, name: str, elem: object):
382382
self.ui_window_elements[f"{name}_cb"] = SimpleCheckBox(
383383
model=omni.ui.SimpleBoolModel(),
384384
enabled=elem.has_debug_vis_implementation,
385-
checked=elem.cfg.debug_vis,
385+
checked=elem.cfg.debug_vis if elem.cfg else False,
386386
on_checked_fn=lambda value, e=weakref.proxy(elem): e.set_debug_vis(value),
387387
)
388388
omni.isaac.ui.ui_utils.add_line_rect_flourish()

source/extensions/omni.isaac.lab/omni/isaac/lab/sensors/ray_caster/ray_caster_camera.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __str__(self) -> str:
8787
f"Ray-Caster-Camera @ '{self.cfg.prim_path}': \n"
8888
f"\tview type : {self._view.__class__}\n"
8989
f"\tupdate period (s) : {self.cfg.update_period}\n"
90-
f"\tnumber of meshes : {len(RayCaster.meshes)}\n"
90+
f"\tnumber of meshes : {len(self.meshes)}\n"
9191
f"\tnumber of sensors : {self._view.count}\n"
9292
f"\tnumber of rays/sensor: {self.num_rays}\n"
9393
f"\ttotal number of rays : {self.num_rays * self._view.count}\n"
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Copyright (c) 2022-2024, The Isaac Lab Project Developers.
2+
# All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
# ignore private usage of variables warning
7+
# pyright: reportPrivateUsage=none
8+
9+
from __future__ import annotations
10+
11+
"""Launch Isaac Sim Simulator first."""
12+
13+
from omni.isaac.lab.app import AppLauncher, run_tests
14+
15+
# Can set this to False to see the GUI for debugging
16+
HEADLESS = True
17+
18+
# launch omniverse app
19+
app_launcher = AppLauncher(headless=HEADLESS, enable_cameras=True)
20+
simulation_app = app_launcher.app
21+
22+
"""Rest everything follows."""
23+
24+
import unittest
25+
26+
import carb
27+
import omni.usd
28+
from omni.isaac.core.utils.extensions import enable_extension
29+
30+
from omni.isaac.lab.envs import ManagerBasedRLEnv, ManagerBasedRLEnvCfg
31+
from omni.isaac.lab.envs.ui import ManagerBasedRLEnvWindow
32+
from omni.isaac.lab.scene import InteractiveSceneCfg
33+
from omni.isaac.lab.utils import configclass
34+
35+
enable_extension("omni.isaac.ui")
36+
37+
38+
@configclass
39+
class EmptyManagerCfg:
40+
"""Empty manager specifications for the environment."""
41+
42+
pass
43+
44+
45+
@configclass
46+
class EmptySceneCfg(InteractiveSceneCfg):
47+
"""Configuration for an empty scene."""
48+
49+
pass
50+
51+
52+
def get_empty_base_env_cfg(device: str = "cuda:0", num_envs: int = 1, env_spacing: float = 1.0):
53+
"""Generate base environment config based on device"""
54+
55+
@configclass
56+
class EmptyEnvCfg(ManagerBasedRLEnvCfg):
57+
"""Configuration for the empty test environment."""
58+
59+
# Scene settings
60+
scene: EmptySceneCfg = EmptySceneCfg(num_envs=num_envs, env_spacing=env_spacing)
61+
# Basic settings
62+
actions: EmptyManagerCfg = EmptyManagerCfg()
63+
observations: EmptyManagerCfg = EmptyManagerCfg()
64+
rewards: EmptyManagerCfg = EmptyManagerCfg()
65+
terminations: EmptyManagerCfg = EmptyManagerCfg()
66+
# Define window
67+
ui_window_class_type: ManagerBasedRLEnvWindow = ManagerBasedRLEnvWindow
68+
69+
def __post_init__(self):
70+
"""Post initialization."""
71+
# step settings
72+
self.decimation = 4 # env step every 4 sim steps: 200Hz / 4 = 50Hz
73+
# simulation settings
74+
self.sim.dt = 0.005 # sim step every 5ms: 200Hz
75+
self.sim.render_interval = self.decimation # render every 4 sim steps
76+
# pass device down from test
77+
self.sim.device = device
78+
# episode length
79+
self.episode_length_s = 5.0
80+
81+
return EmptyEnvCfg()
82+
83+
84+
class TestManagerBasedRLEnvUI(unittest.TestCase):
85+
"""Test for manager-based RL env class UI"""
86+
87+
"""
88+
Tests
89+
"""
90+
91+
def test_ui_window(self):
92+
device = "cuda:0"
93+
# override sim setting to enable UI
94+
carb.settings.get_settings().set_bool("/app/window/enabled", True)
95+
# create a new stage
96+
omni.usd.get_context().new_stage()
97+
# create environment
98+
env = ManagerBasedRLEnv(cfg=get_empty_base_env_cfg(device=device))
99+
# close the environment
100+
env.close()
101+
102+
103+
if __name__ == "__main__":
104+
run_tests()

source/extensions/omni.isaac.lab/test/sensors/test_camera.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,15 @@ def test_throughput(self):
719719
for im_data in camera.data.output.values():
720720
self.assertEqual(im_data.shape, (1, camera_cfg.height, camera_cfg.width, 1))
721721

722+
def test_sensor_print(self):
723+
"""Test sensor print is working correctly."""
724+
# Create sensor
725+
sensor = Camera(cfg=self.camera_cfg)
726+
# Play sim
727+
self.sim.reset()
728+
# print info
729+
print(sensor)
730+
722731
"""
723732
Helper functions.
724733
"""

source/extensions/omni.isaac.lab/test/sensors/test_contact_sensor.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,27 @@ def test_cube_stack_contact_filtering(self):
294294
contact_sensor_2.data.force_matrix_w[:, :, 0], contact_sensor.data.force_matrix_w[:, :, 0]
295295
)
296296

297+
def test_sensor_print(self):
298+
"""Test sensor print is working correctly."""
299+
with build_simulation_context(device="cuda:0", dt=self.sim_dt, add_lighting=False) as sim:
300+
# Spawn things into stage
301+
scene_cfg = ContactSensorSceneCfg(num_envs=1, env_spacing=1.0, lazy_sensor_update=False)
302+
scene_cfg.terrain = FLAT_TERRAIN_CFG.replace(prim_path="/World/ground")
303+
scene_cfg.shape = CUBE_CFG
304+
scene_cfg.contact_sensor = ContactSensorCfg(
305+
prim_path=scene_cfg.shape.prim_path,
306+
track_pose=True,
307+
debug_vis=False,
308+
update_period=0.0,
309+
track_air_time=True,
310+
history_length=3,
311+
)
312+
scene = InteractiveScene(scene_cfg)
313+
# Play the simulator
314+
sim.reset()
315+
# print info
316+
print(scene.sensors["contact_sensor"])
317+
297318
"""
298319
Internal helpers.
299320
"""

source/extensions/omni.isaac.lab/test/sensors/test_frame_transformer.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,25 @@ def test_frame_transformer_all_bodies(self):
579579
torch.testing.assert_close(bodies_pos_source_tf[:, index], body_pos_b)
580580
torch.testing.assert_close(bodies_quat_source_tf[:, index], body_quat_b)
581581

582+
def test_sensor_print(self):
583+
"""Test sensor print is working correctly."""
584+
# Spawn things into stage
585+
scene_cfg = MySceneCfg(num_envs=2, env_spacing=5.0, lazy_sensor_update=False)
586+
scene_cfg.frame_transformer = FrameTransformerCfg(
587+
prim_path="{ENV_REGEX_NS}/Robot/base",
588+
target_frames=[
589+
FrameTransformerCfg.FrameCfg(
590+
prim_path="{ENV_REGEX_NS}/Robot/.*",
591+
),
592+
],
593+
)
594+
scene = InteractiveScene(scene_cfg)
595+
596+
# Play the simulator
597+
self.sim.reset()
598+
# print info
599+
print(scene.sensors["frame_transformer"])
600+
582601

583602
if __name__ == "__main__":
584603
run_tests()

source/extensions/omni.isaac.lab/test/sensors/test_imu.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -498,34 +498,40 @@ def test_offset_calculation(self):
498498
atol=1e-4,
499499
)
500500

501+
def test_env_ids_propogation(self):
502+
"""Test that env_ids argument propagates through update and reset methods"""
503+
self.scene.reset()
501504

502-
def test_env_ids_propogation(self):
503-
"""Test that env_ids argument propagates through update and reset methods"""
504-
self.scene.reset()
505-
506-
for idx in range(10):
507-
# set acceleration
508-
self.scene.articulations["robot"].write_root_velocity_to_sim(
509-
torch.tensor([[0.5, 0.0, 0.0, 0.0, 0.0, 0.0]], dtype=torch.float32, device=self.scene.device).repeat(
510-
self.scene.num_envs, 1
505+
for idx in range(10):
506+
# set acceleration
507+
self.scene.articulations["robot"].write_root_velocity_to_sim(
508+
torch.tensor([[0.5, 0.0, 0.0, 0.0, 0.0, 0.0]], dtype=torch.float32, device=self.scene.device).repeat(
509+
self.scene.num_envs, 1
510+
)
511+
* (idx + 1)
511512
)
512-
* (idx + 1)
513-
)
514-
# write data to sim
515-
self.scene.write_data_to_sim()
513+
# write data to sim
514+
self.scene.write_data_to_sim()
515+
# perform step
516+
self.sim.step()
517+
# read data from sim
518+
self.scene.update(self.sim.get_physics_dt())
519+
520+
# reset scene for env 1
521+
self.scene.reset(env_ids=[1])
522+
# read data from sim
523+
self.scene.update(self.sim.get_physics_dt())
516524
# perform step
517525
self.sim.step()
518526
# read data from sim
519527
self.scene.update(self.sim.get_physics_dt())
520528

521-
# reset scene for env 1
522-
self.scene.reset(env_ids=[1])
523-
# read data from sim
524-
self.scene.update(self.sim.get_physics_dt())
525-
# perform step
526-
self.sim.step()
527-
# read data from sim
528-
self.scene.update(self.sim.get_physics_dt())
529+
def test_sensor_print(self):
530+
"""Test sensor print is working correctly."""
531+
# Create sensor
532+
sensor = self.scene.sensors["imu_ball"]
533+
# print info
534+
print(sensor)
529535

530536

531537
if __name__ == "__main__":

source/extensions/omni.isaac.lab/test/sensors/test_ray_caster_camera.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,15 @@ def test_output_equal_to_usd_camera_when_intrinsics_set(self):
817817
atol=1e-4,
818818
)
819819

820+
def test_sensor_print(self):
821+
"""Test sensor print is working correctly."""
822+
# Create sensor
823+
sensor = RayCasterCamera(cfg=self.camera_cfg)
824+
# Play sim
825+
self.sim.reset()
826+
# print info
827+
print(sensor)
828+
820829

821830
if __name__ == "__main__":
822831
run_tests()

0 commit comments

Comments
 (0)