Unverified Commit 05b52e7f authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Fixes import inside InteractiveScene and LiveVisualizer (#2611)

# Description

The imports for `omni.log` was missing. In the other file, carb was used
(incorrectly) instead of omni.log.

## 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`
- [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
- [ ] 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 dca126ac
...@@ -8,6 +8,7 @@ from collections.abc import Sequence ...@@ -8,6 +8,7 @@ from collections.abc import Sequence
from typing import Any from typing import Any
import carb import carb
import omni.log
import omni.usd import omni.usd
from isaacsim.core.cloner import GridCloner from isaacsim.core.cloner import GridCloner
from isaacsim.core.prims import XFormPrim from isaacsim.core.prims import XFormPrim
...@@ -621,7 +622,12 @@ class InteractiveScene: ...@@ -621,7 +622,12 @@ class InteractiveScene:
Internal methods. Internal methods.
""" """
def _is_scene_setup_from_cfg(self): def _is_scene_setup_from_cfg(self) -> bool:
"""Check if scene entities are setup from the config or not.
Returns:
True if scene entities are setup from the config, False otherwise.
"""
return any( return any(
not (asset_name in InteractiveSceneCfg.__dataclass_fields__ or asset_cfg is None) not (asset_name in InteractiveSceneCfg.__dataclass_fields__ or asset_cfg is None)
for asset_name, asset_cfg in self.cfg.__dict__.items() for asset_name, asset_cfg in self.cfg.__dict__.items()
......
...@@ -10,8 +10,8 @@ import weakref ...@@ -10,8 +10,8 @@ import weakref
from dataclasses import MISSING from dataclasses import MISSING
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import carb
import omni.kit.app import omni.kit.app
import omni.log
from isaacsim.core.api.simulation_context import SimulationContext from isaacsim.core.api.simulation_context import SimulationContext
from isaaclab.managers import ManagerBase from isaaclab.managers import ManagerBase
...@@ -27,12 +27,14 @@ if TYPE_CHECKING: ...@@ -27,12 +27,14 @@ if TYPE_CHECKING:
@configclass @configclass
class ManagerLiveVisualizerCfg: class ManagerLiveVisualizerCfg:
"Configuration for ManagerLiveVisualizer" """Configuration for the :class:`ManagerLiveVisualizer` class."""
debug_vis: bool = False debug_vis: bool = False
"""Flag used to set status of the live visualizers on startup. Defaults to closed.""" """Flag used to set status of the live visualizers on startup. Defaults to False, which means closed."""
manager_name: str = MISSING manager_name: str = MISSING
"""Manager name that corresponds to the manager of interest in the ManagerBasedEnv and ManagerBasedRLEnv""" """Manager name that corresponds to the manager of interest in the ManagerBasedEnv and ManagerBasedRLEnv"""
term_names: list[str] | dict[str, list[str]] | None = None term_names: list[str] | dict[str, list[str]] | None = None
"""Specific term names specified in a Manager config that are chosen to be plotted. Defaults to None. """Specific term names specified in a Manager config that are chosen to be plotted. Defaults to None.
...@@ -42,15 +44,20 @@ class ManagerLiveVisualizerCfg: ...@@ -42,15 +44,20 @@ class ManagerLiveVisualizerCfg:
class ManagerLiveVisualizer(UiVisualizerBase): class ManagerLiveVisualizer(UiVisualizerBase):
"""A interface object used to transfer data from a manager to a UI widget. This class handles the creation of UI """A interface object used to transfer data from a manager to a UI widget.
Widgets for selected terms given a ManagerLiveVisualizerCfg.
This class handles the creation of UI Widgets for selected terms given a :class:`ManagerLiveVisualizerCfg`.
It iterates through the terms of the manager and creates a visualizer for each term. If the term is a single
variable or a multi-variable signal, it creates a :class:`LiveLinePlot`. If the term is an image (2D or RGB),
it creates an :class:`ImagePlot`. The visualizer can be toggled on and off using the
:attr:`ManagerLiveVisualizerCfg.debug_vis` flag in the configuration.
""" """
def __init__(self, manager: ManagerBase, cfg: ManagerLiveVisualizerCfg = ManagerLiveVisualizerCfg()): def __init__(self, manager: ManagerBase, cfg: ManagerLiveVisualizerCfg = ManagerLiveVisualizerCfg()):
"""Initialize ManagerLiveVisualizer. """Initialize ManagerLiveVisualizer.
Args: Args:
manager: The manager with terms to be plotted. The manager must have a get_active_iterable_terms method. manager: The manager with terms to be plotted. The manager must have a :meth:`get_active_iterable_terms` method.
cfg: The configuration file used to select desired manager terms to be plotted. cfg: The configuration file used to select desired manager terms to be plotted.
""" """
...@@ -72,7 +79,7 @@ class ManagerLiveVisualizer(UiVisualizerBase): ...@@ -72,7 +79,7 @@ class ManagerLiveVisualizer(UiVisualizerBase):
if term_name in self._manager.active_terms: if term_name in self._manager.active_terms:
self.term_names.append(term_name) self.term_names.append(term_name)
else: else:
carb.log_err( omni.log.error(
f"ManagerVisualizer Failure: ManagerTerm ({term_name}) does not exist in" f"ManagerVisualizer Failure: ManagerTerm ({term_name}) does not exist in"
f" Manager({self.cfg.manager_name})" f" Manager({self.cfg.manager_name})"
) )
...@@ -87,17 +94,17 @@ class ManagerLiveVisualizer(UiVisualizerBase): ...@@ -87,17 +94,17 @@ class ManagerLiveVisualizer(UiVisualizerBase):
if term_name in self._manager.active_terms[group]: if term_name in self._manager.active_terms[group]:
self.term_names.append(f"{group}-{term_name}") self.term_names.append(f"{group}-{term_name}")
else: else:
carb.log_err( omni.log.error(
f"ManagerVisualizer Failure: ManagerTerm ({term_name}) does not exist in" f"ManagerVisualizer Failure: ManagerTerm ({term_name}) does not exist in"
f" Group({group})" f" Group({group})"
) )
else: else:
carb.log_err( omni.log.error(
f"ManagerVisualizer Failure: Group ({group}) does not exist in" f"ManagerVisualizer Failure: Group ({group}) does not exist in"
f" Manager({self.cfg.manager_name})" f" Manager({self.cfg.manager_name})"
) )
else: else:
carb.log_err( omni.log.error(
f"ManagerVisualizer Failure: Manager({self.cfg.manager_name}) does not utilize grouping of" f"ManagerVisualizer Failure: Manager({self.cfg.manager_name}) does not utilize grouping of"
" terms." " terms."
) )
...@@ -108,12 +115,12 @@ class ManagerLiveVisualizer(UiVisualizerBase): ...@@ -108,12 +115,12 @@ class ManagerLiveVisualizer(UiVisualizerBase):
@property @property
def get_vis_frame(self) -> omni.ui.Frame: def get_vis_frame(self) -> omni.ui.Frame:
"""Getter for the UI Frame object tied to this visualizer.""" """Returns the UI Frame object tied to this visualizer."""
return self._vis_frame return self._vis_frame
@property @property
def get_vis_window(self) -> omni.ui.Window: def get_vis_window(self) -> omni.ui.Window:
"""Getter for the UI Window object tied to this visualizer.""" """Returns the UI Window object tied to this visualizer."""
return self._vis_window return self._vis_window
# #
...@@ -141,7 +148,7 @@ class ManagerLiveVisualizer(UiVisualizerBase): ...@@ -141,7 +148,7 @@ class ManagerLiveVisualizer(UiVisualizerBase):
if env_idx > 0 and env_idx < self._manager.num_envs: if env_idx > 0 and env_idx < self._manager.num_envs:
self._env_idx = env_idx self._env_idx = env_idx
else: else:
carb.log_warn(f"Environment index is out of range (0,{self._manager.num_envs})") omni.log.warn(f"Environment index is out of range (0, {self._manager.num_envs - 1})")
def _set_vis_frame_impl(self, frame: omni.ui.Frame): def _set_vis_frame_impl(self, frame: omni.ui.Frame):
"""Updates the assigned frame that can be used for visualizations. """Updates the assigned frame that can be used for visualizations.
...@@ -210,24 +217,17 @@ class ManagerLiveVisualizer(UiVisualizerBase): ...@@ -210,24 +217,17 @@ class ManagerLiveVisualizer(UiVisualizerBase):
style={"border_color": 0xFF8A8777, "padding": 4}, style={"border_color": 0xFF8A8777, "padding": 4},
) )
with frame: with frame:
# create line plot for single or multivariable signals # create line plot for single or multi-variable signals
len_term_shape = len(numpy.array(term).shape) len_term_shape = len(numpy.array(term).shape)
if len_term_shape <= 2: if len_term_shape <= 2:
plot = LiveLinePlot( plot = LiveLinePlot(y_data=[[elem] for elem in term], plot_height=150, show_legend=True)
y_data=[[elem] for elem in term],
plot_height=150,
show_legend=True,
)
self._term_visualizers.append(plot) self._term_visualizers.append(plot)
# create an image plot for 2d and greater data (i.e. mono and rgb images) # create an image plot for 2d and greater data (i.e. mono and rgb images)
elif len_term_shape == 3: elif len_term_shape == 3:
image = ImagePlot( image = ImagePlot(image=numpy.array(term), label=name)
image=numpy.array(term),
label=name,
)
self._term_visualizers.append(image) self._term_visualizers.append(image)
else: else:
carb.log_warn( omni.log.warn(
f"ManagerLiveVisualizer: Term ({name}) is not a supported data type for" f"ManagerLiveVisualizer: Term ({name}) is not a supported data type for"
" visualization." " visualization."
) )
......
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