Skip to content

Commit

Permalink
Updates sensor data always if visualization enabled
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
renezurbruegg committed Nov 28, 2023
1 parent 7b0db15 commit 4565902
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/extensions/omni.isaac.orbit/config/extension.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
17 changes: 17 additions & 0 deletions source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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)
~~~~~~~~~~~~~~~~~~~

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()

"""
Expand Down

0 comments on commit 4565902

Please sign in to comment.