Unverified Commit cace5c50 authored by Kelly Guo's avatar Kelly Guo Committed by GitHub

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
parent 1e3b6ec2
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.27.5" version = "0.27.6"
# Description # Description
title = "Isaac Lab framework for Robot Learning" title = "Isaac Lab framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.27.6 (2024-10-25)
~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed usage of ``meshes`` property in :class:`omni.isaac.lab.sensors.RayCasterCamera` to use ``self.meshes`` instead of the undefined ``RayCaster.meshes``.
* Fixed issue in :class:`omni.isaac.lab.envs.ui.BaseEnvWindow` where undefined configs were being accessed when creating debug visualization elements in UI.
0.27.5 (2024-10-25) 0.27.5 (2024-10-25)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
......
...@@ -382,7 +382,7 @@ class BaseEnvWindow: ...@@ -382,7 +382,7 @@ class BaseEnvWindow:
self.ui_window_elements[f"{name}_cb"] = SimpleCheckBox( self.ui_window_elements[f"{name}_cb"] = SimpleCheckBox(
model=omni.ui.SimpleBoolModel(), model=omni.ui.SimpleBoolModel(),
enabled=elem.has_debug_vis_implementation, enabled=elem.has_debug_vis_implementation,
checked=elem.cfg.debug_vis, checked=elem.cfg.debug_vis if elem.cfg else False,
on_checked_fn=lambda value, e=weakref.proxy(elem): e.set_debug_vis(value), on_checked_fn=lambda value, e=weakref.proxy(elem): e.set_debug_vis(value),
) )
omni.isaac.ui.ui_utils.add_line_rect_flourish() omni.isaac.ui.ui_utils.add_line_rect_flourish()
......
...@@ -87,7 +87,7 @@ class RayCasterCamera(RayCaster): ...@@ -87,7 +87,7 @@ class RayCasterCamera(RayCaster):
f"Ray-Caster-Camera @ '{self.cfg.prim_path}': \n" f"Ray-Caster-Camera @ '{self.cfg.prim_path}': \n"
f"\tview type : {self._view.__class__}\n" f"\tview type : {self._view.__class__}\n"
f"\tupdate period (s) : {self.cfg.update_period}\n" f"\tupdate period (s) : {self.cfg.update_period}\n"
f"\tnumber of meshes : {len(RayCaster.meshes)}\n" f"\tnumber of meshes : {len(self.meshes)}\n"
f"\tnumber of sensors : {self._view.count}\n" f"\tnumber of sensors : {self._view.count}\n"
f"\tnumber of rays/sensor: {self.num_rays}\n" f"\tnumber of rays/sensor: {self.num_rays}\n"
f"\ttotal number of rays : {self.num_rays * self._view.count}\n" f"\ttotal number of rays : {self.num_rays * self._view.count}\n"
......
# Copyright (c) 2022-2024, The Isaac Lab Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
# ignore private usage of variables warning
# pyright: reportPrivateUsage=none
from __future__ import annotations
"""Launch Isaac Sim Simulator first."""
from omni.isaac.lab.app import AppLauncher, run_tests
# Can set this to False to see the GUI for debugging
HEADLESS = True
# launch omniverse app
app_launcher = AppLauncher(headless=HEADLESS, enable_cameras=True)
simulation_app = app_launcher.app
"""Rest everything follows."""
import unittest
import carb
import omni.usd
from omni.isaac.core.utils.extensions import enable_extension
from omni.isaac.lab.envs import ManagerBasedRLEnv, ManagerBasedRLEnvCfg
from omni.isaac.lab.envs.ui import ManagerBasedRLEnvWindow
from omni.isaac.lab.scene import InteractiveSceneCfg
from omni.isaac.lab.utils import configclass
enable_extension("omni.isaac.ui")
@configclass
class EmptyManagerCfg:
"""Empty manager specifications for the environment."""
pass
@configclass
class EmptySceneCfg(InteractiveSceneCfg):
"""Configuration for an empty scene."""
pass
def get_empty_base_env_cfg(device: str = "cuda:0", num_envs: int = 1, env_spacing: float = 1.0):
"""Generate base environment config based on device"""
@configclass
class EmptyEnvCfg(ManagerBasedRLEnvCfg):
"""Configuration for the empty test environment."""
# Scene settings
scene: EmptySceneCfg = EmptySceneCfg(num_envs=num_envs, env_spacing=env_spacing)
# Basic settings
actions: EmptyManagerCfg = EmptyManagerCfg()
observations: EmptyManagerCfg = EmptyManagerCfg()
rewards: EmptyManagerCfg = EmptyManagerCfg()
terminations: EmptyManagerCfg = EmptyManagerCfg()
# Define window
ui_window_class_type: ManagerBasedRLEnvWindow = ManagerBasedRLEnvWindow
def __post_init__(self):
"""Post initialization."""
# step settings
self.decimation = 4 # env step every 4 sim steps: 200Hz / 4 = 50Hz
# simulation settings
self.sim.dt = 0.005 # sim step every 5ms: 200Hz
self.sim.render_interval = self.decimation # render every 4 sim steps
# pass device down from test
self.sim.device = device
# episode length
self.episode_length_s = 5.0
return EmptyEnvCfg()
class TestManagerBasedRLEnvUI(unittest.TestCase):
"""Test for manager-based RL env class UI"""
"""
Tests
"""
def test_ui_window(self):
device = "cuda:0"
# override sim setting to enable UI
carb.settings.get_settings().set_bool("/app/window/enabled", True)
# create a new stage
omni.usd.get_context().new_stage()
# create environment
env = ManagerBasedRLEnv(cfg=get_empty_base_env_cfg(device=device))
# close the environment
env.close()
if __name__ == "__main__":
run_tests()
...@@ -719,6 +719,15 @@ class TestCamera(unittest.TestCase): ...@@ -719,6 +719,15 @@ class TestCamera(unittest.TestCase):
for im_data in camera.data.output.values(): for im_data in camera.data.output.values():
self.assertEqual(im_data.shape, (1, camera_cfg.height, camera_cfg.width, 1)) self.assertEqual(im_data.shape, (1, camera_cfg.height, camera_cfg.width, 1))
def test_sensor_print(self):
"""Test sensor print is working correctly."""
# Create sensor
sensor = Camera(cfg=self.camera_cfg)
# Play sim
self.sim.reset()
# print info
print(sensor)
""" """
Helper functions. Helper functions.
""" """
......
...@@ -294,6 +294,27 @@ class TestContactSensor(unittest.TestCase): ...@@ -294,6 +294,27 @@ class TestContactSensor(unittest.TestCase):
contact_sensor_2.data.force_matrix_w[:, :, 0], contact_sensor.data.force_matrix_w[:, :, 0] contact_sensor_2.data.force_matrix_w[:, :, 0], contact_sensor.data.force_matrix_w[:, :, 0]
) )
def test_sensor_print(self):
"""Test sensor print is working correctly."""
with build_simulation_context(device="cuda:0", dt=self.sim_dt, add_lighting=False) as sim:
# Spawn things into stage
scene_cfg = ContactSensorSceneCfg(num_envs=1, env_spacing=1.0, lazy_sensor_update=False)
scene_cfg.terrain = FLAT_TERRAIN_CFG.replace(prim_path="/World/ground")
scene_cfg.shape = CUBE_CFG
scene_cfg.contact_sensor = ContactSensorCfg(
prim_path=scene_cfg.shape.prim_path,
track_pose=True,
debug_vis=False,
update_period=0.0,
track_air_time=True,
history_length=3,
)
scene = InteractiveScene(scene_cfg)
# Play the simulator
sim.reset()
# print info
print(scene.sensors["contact_sensor"])
""" """
Internal helpers. Internal helpers.
""" """
......
...@@ -579,6 +579,25 @@ class TestFrameTransformer(unittest.TestCase): ...@@ -579,6 +579,25 @@ class TestFrameTransformer(unittest.TestCase):
torch.testing.assert_close(bodies_pos_source_tf[:, index], body_pos_b) torch.testing.assert_close(bodies_pos_source_tf[:, index], body_pos_b)
torch.testing.assert_close(bodies_quat_source_tf[:, index], body_quat_b) torch.testing.assert_close(bodies_quat_source_tf[:, index], body_quat_b)
def test_sensor_print(self):
"""Test sensor print is working correctly."""
# Spawn things into stage
scene_cfg = MySceneCfg(num_envs=2, env_spacing=5.0, lazy_sensor_update=False)
scene_cfg.frame_transformer = FrameTransformerCfg(
prim_path="{ENV_REGEX_NS}/Robot/base",
target_frames=[
FrameTransformerCfg.FrameCfg(
prim_path="{ENV_REGEX_NS}/Robot/.*",
),
],
)
scene = InteractiveScene(scene_cfg)
# Play the simulator
self.sim.reset()
# print info
print(scene.sensors["frame_transformer"])
if __name__ == "__main__": if __name__ == "__main__":
run_tests() run_tests()
...@@ -498,34 +498,40 @@ class TestImu(unittest.TestCase): ...@@ -498,34 +498,40 @@ class TestImu(unittest.TestCase):
atol=1e-4, atol=1e-4,
) )
def test_env_ids_propogation(self):
"""Test that env_ids argument propagates through update and reset methods"""
self.scene.reset()
def test_env_ids_propogation(self): for idx in range(10):
"""Test that env_ids argument propagates through update and reset methods""" # set acceleration
self.scene.reset() self.scene.articulations["robot"].write_root_velocity_to_sim(
torch.tensor([[0.5, 0.0, 0.0, 0.0, 0.0, 0.0]], dtype=torch.float32, device=self.scene.device).repeat(
for idx in range(10): self.scene.num_envs, 1
# set acceleration )
self.scene.articulations["robot"].write_root_velocity_to_sim( * (idx + 1)
torch.tensor([[0.5, 0.0, 0.0, 0.0, 0.0, 0.0]], dtype=torch.float32, device=self.scene.device).repeat(
self.scene.num_envs, 1
) )
* (idx + 1) # write data to sim
) self.scene.write_data_to_sim()
# write data to sim # perform step
self.scene.write_data_to_sim() self.sim.step()
# read data from sim
self.scene.update(self.sim.get_physics_dt())
# reset scene for env 1
self.scene.reset(env_ids=[1])
# read data from sim
self.scene.update(self.sim.get_physics_dt())
# perform step # perform step
self.sim.step() self.sim.step()
# read data from sim # read data from sim
self.scene.update(self.sim.get_physics_dt()) self.scene.update(self.sim.get_physics_dt())
# reset scene for env 1 def test_sensor_print(self):
self.scene.reset(env_ids=[1]) """Test sensor print is working correctly."""
# read data from sim # Create sensor
self.scene.update(self.sim.get_physics_dt()) sensor = self.scene.sensors["imu_ball"]
# perform step # print info
self.sim.step() print(sensor)
# read data from sim
self.scene.update(self.sim.get_physics_dt())
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -817,6 +817,15 @@ class TestWarpCamera(unittest.TestCase): ...@@ -817,6 +817,15 @@ class TestWarpCamera(unittest.TestCase):
atol=1e-4, atol=1e-4,
) )
def test_sensor_print(self):
"""Test sensor print is working correctly."""
# Create sensor
sensor = RayCasterCamera(cfg=self.camera_cfg)
# Play sim
self.sim.reset()
# print info
print(sensor)
if __name__ == "__main__": if __name__ == "__main__":
run_tests() run_tests()
...@@ -1304,6 +1304,15 @@ class TestTiledCamera(unittest.TestCase): ...@@ -1304,6 +1304,15 @@ class TestTiledCamera(unittest.TestCase):
del camera_tiled del camera_tiled
del camera_usd del camera_usd
def test_sensor_print(self):
"""Test sensor print is working correctly."""
# Create sensor
sensor = TiledCamera(cfg=self.camera_cfg)
# Play sim
self.sim.reset()
# print info
print(sensor)
""" """
Helper functions. Helper functions.
""" """
......
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