From 4565902f519a5bc983027db899718745bb827df5 Mon Sep 17 00:00:00 2001 From: renezurbruegg Date: Tue, 28 Nov 2023 23:20:52 +0100 Subject: [PATCH] Updates sensor data always if visualization enabled # Description This MR ensures that the sensor buffers are always updated in visualization mode. Otherwise, the sensors are not visualizable without someone accessing the `data` property. ## Type of change - New feature (non-breaking change which adds functionality) ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./orbit.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] 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 --- .../omni.isaac.orbit/config/extension.toml | 2 +- .../omni.isaac.orbit/docs/CHANGELOG.rst | 17 +++++++++++++++++ .../omni/isaac/orbit/scene/interactive_scene.py | 5 ++++- .../frame_transformer/frame_transformer.py | 8 +++++++- .../omni/isaac/orbit/sensors/sensor_base.py | 6 +++++- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/source/extensions/omni.isaac.orbit/config/extension.toml b/source/extensions/omni.isaac.orbit/config/extension.toml index 4b1cb25295..cf1584a907 100644 --- a/source/extensions/omni.isaac.orbit/config/extension.toml +++ b/source/extensions/omni.isaac.orbit/config/extension.toml @@ -1,7 +1,7 @@ [package] # Note: Semantic Versioning is used: https://semver.org/ -version = "0.9.50" +version = "0.9.51" # Description title = "ORBIT framework for Robot Learning" diff --git a/source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst b/source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst index 5712bffd6e..55e440cd7a 100644 --- a/source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst +++ b/source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst @@ -1,6 +1,23 @@ Changelog --------- +0.9.51 (2023-11-29) +~~~~~~~~~~~~~~~~~~~ + +Changed +^^^^^^^ + +* Changed the :meth:`omni.isaac.orbit.sensor.SensorBase.update` method to always recompute the buffers if + the sensor is in visualization mode. + +Added +^^^^^ + +* Added available entities to the error message when accessing a non-existent entity in the + :class:`InteractiveScene` class. +* Added a warning message when the user tries to reference an invalid prim in the :class:`FrameTransformer` sensor. + + 0.9.50 (2023-11-28) ~~~~~~~~~~~~~~~~~~~ diff --git a/source/extensions/omni.isaac.orbit/omni/isaac/orbit/scene/interactive_scene.py b/source/extensions/omni.isaac.orbit/omni/isaac/orbit/scene/interactive_scene.py index b95339ba4a..ee011bc8d2 100644 --- a/source/extensions/omni.isaac.orbit/omni/isaac/orbit/scene/interactive_scene.py +++ b/source/extensions/omni.isaac.orbit/omni/isaac/orbit/scene/interactive_scene.py @@ -306,14 +306,17 @@ def __getitem__(self, key: str) -> Any: # check if it is a terrain if key == "terrain": return self.terrain + + all_keys = ["terrain"] # check if it is in other dictionaries for asset_family in [self.articulations, self.rigid_objects, self.sensors, self.extras]: out = asset_family.get(key) # if found, return if out is not None: return out + all_keys += list(asset_family.keys()) # if not found, raise error - raise KeyError(f"Scene entity with key '{key}' not found.") + raise KeyError(f"Scene entity with key '{key}' not found. Available Entities: '{all_keys}'") """ Internal methods. diff --git a/source/extensions/omni.isaac.orbit/omni/isaac/orbit/sensors/frame_transformer/frame_transformer.py b/source/extensions/omni.isaac.orbit/omni/isaac/orbit/sensors/frame_transformer/frame_transformer.py index c59ad2e75c..47d9767e61 100644 --- a/source/extensions/omni.isaac.orbit/omni/isaac/orbit/sensors/frame_transformer/frame_transformer.py +++ b/source/extensions/omni.isaac.orbit/omni/isaac/orbit/sensors/frame_transformer/frame_transformer.py @@ -151,7 +151,13 @@ def _initialize_impl(self): frame_offsets = [None] + [target_frame.offset for target_frame in self.cfg.target_frames] for frame, prim_path, offset in zip(frames, frame_prim_paths, frame_offsets): # Find correct prim - for matching_prim_path in prim_utils.find_matching_prim_paths(prim_path): + matching_prims = prim_utils.find_matching_prim_paths(prim_path) + if len(matching_prims) == 0: + raise ValueError( + f"Failed to create frame transformer for frame '{frame}' with path '{prim_path}'." + " No matching prims were found." + ) + for matching_prim_path in matching_prims: prim = prim_utils.get_prim_at_path(matching_prim_path) # check if it is a rigid prim if not prim.HasAPI(UsdPhysics.RigidBodyAPI): diff --git a/source/extensions/omni.isaac.orbit/omni/isaac/orbit/sensors/sensor_base.py b/source/extensions/omni.isaac.orbit/omni/isaac/orbit/sensors/sensor_base.py index 2c658c53b3..462f67b1e7 100644 --- a/source/extensions/omni.isaac.orbit/omni/isaac/orbit/sensors/sensor_base.py +++ b/source/extensions/omni.isaac.orbit/omni/isaac/orbit/sensors/sensor_base.py @@ -51,6 +51,8 @@ def __init__(self, cfg: SensorBaseCfg): self.cfg = cfg # flag for whether the sensor is initialized self._is_initialized = False + # flag for whether the sensor is in visualization mode + self._is_visualizing = False # note: Use weakref on callbacks to ensure that this object can be deleted when its destructor is called. # add callbacks for stage play/stop @@ -140,6 +142,8 @@ def set_debug_vis(self, debug_vis: bool) -> bool: return False # toggle debug visualization objects self._set_debug_vis_impl(debug_vis) + # toggle debug visualization flag + self._is_visualizing = debug_vis # toggle debug visualization handles if debug_vis: # create a subscriber for the post update event if it doesn't exist @@ -178,7 +182,7 @@ def update(self, dt: float, force_recompute: bool = False): # Update the buffers # TODO (from @mayank): Why is there a history length here when it doesn't mean anything in the sensor base?!? # It is only for the contact sensor but there we should redefine the update function IMO. - if force_recompute or (self.cfg.history_length > 0): + if force_recompute or self._is_visualizing or (self.cfg.history_length > 0): self._update_outdated_buffers() """