Skip to content

Commit

Permalink
fixes and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-roth committed Oct 11, 2024
1 parent 3a479ef commit 4fc4be5
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,12 @@ def has_debug_vis_implementation(self) -> bool:

def get_active_iterable_terms(self, env_idx: int) -> Sequence[tuple[str, Sequence[float]]]:
"""Returns the active terms as iterable sequence of tuples.
The first element of the tuple is the name of the term and the second element is the raw value(s) of the term.
Args:
env_idx: The specific environment to pull the active terms from.
Returns:
The active terms.
"""
Expand All @@ -270,7 +273,7 @@ def get_active_iterable_terms(self, env_idx: int) -> Sequence[tuple[str, Sequenc
idx += term.action_dim
return terms

def set_debug_vis(self, debug_vis: bool) -> bool:
def set_debug_vis(self, debug_vis: bool):
"""Sets whether to visualize the action data.
Args:
debug_vis: Whether to visualize the action data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,22 +293,24 @@ def has_debug_vis_implementation(self) -> bool:

def get_active_iterable_terms(self, env_idx: int) -> Sequence[tuple[str, Sequence[float]]]:
"""Returns the active terms as iterable sequence of tuples.
The first element of the tuple is the name of the term and the second element is the raw value(s) of the term.
Args:
env_idx: The specific environment to pull the active terms from.
Returns:
The active terms.
"""

terms = []
idx = 0
for name, term in self._terms.items():
term_commands = self._commands[env_idx, idx : idx + term.command.shape[1]].cpu()
terms.append((name, term_commands.tolist()))
terms.append((name, term.command[env_idx].cpu().tolist()))
idx += term.command.shape[1]
return terms

def set_debug_vis(self, debug_vis: bool) -> bool:
def set_debug_vis(self, debug_vis: bool):
"""Sets whether to visualize the command data.
Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,12 @@ def compute(self, env_ids: Sequence[int] | None = None):

def get_active_iterable_terms(self, env_idx: int) -> Sequence[tuple[str, Sequence[float]]]:
"""Returns the active terms as iterable sequence of tuples.
The first element of the tuple is the name of the term and the second element is the raw value(s) of the term.
Args:
env_idx: The specific environment to pull the active terms from.
Returns:
The active terms.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ def find_terms(self, name_keys: str | Sequence[str]) -> list[str]:

def get_active_iterable_terms(self, env_idx: int) -> Sequence[tuple[str, Sequence[float]]]:
"""Returns the active terms as iterable sequence of tuples.
The first element of the tuple is the name of the term and the second element is the raw value(s) of the term.
Returns:
The active terms.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,12 @@ def __str__(self) -> str:

def get_active_iterable_terms(self, env_idx: int) -> Sequence[tuple[str, Sequence[float]]]:
"""Returns the active terms as iterable sequence of tuples.
The first element of the tuple is the name of the term and the second element is the raw value(s) of the term.
Args:
env_idx: The specific environment to pull the active terms from.
Returns:
The active terms.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,12 @@ def get_term_cfg(self, term_name: str) -> RewardTermCfg:

def get_active_iterable_terms(self, env_idx: int) -> Sequence[tuple[str, Sequence[float]]]:
"""Returns the active terms as iterable sequence of tuples.
The first element of the tuple is the name of the term and the second element is the raw value(s) of the term.
Args:
env_idx: The specific environment to pull the active terms from.
Returns:
The active terms.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,12 @@ def get_term(self, name: str) -> torch.Tensor:

def get_active_iterable_terms(self, env_idx: int) -> Sequence[tuple[str, Sequence[float]]]:
"""Returns the active terms as iterable sequence of tuples.
The first element of the tuple is the name of the term and the second element is the raw value(s) of the term.
Args:
env_idx: The specific environment to pull the active terms from.
Returns:
The active terms.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
from omni.ui import CollapsableFrame, Frame, VStack, Window

from omni.isaac.lab.managers import ManagerBase
from omni.isaac.lab.ui.widgets import ImagePlot, LiveLinePlot, UiVisualizerBase
from .image_plot import ImagePlot
from .line_plot import LiveLinePlot
from .ui_visualizer_base import UiVisualizerBase
from omni.isaac.lab.utils import configclass


Expand Down Expand Up @@ -205,20 +207,25 @@ def _set_debug_vis_impl(self, debug_vis: bool) -> None:
)
with frame:
# create line plot for single or multivariable signals
if len(term) <= 2:
if isinstance(term[0], float | int):
plot = LiveLinePlot(
y_data=[[elem] for elem in term],
plot_height=150,
show_legend=True,
)
self._term_visualizers.append(plot)
# create an image plot for 2d and greater data (i.e. mono and rgb images)
elif len(term) > 2:
elif isinstance(term[0], list) and isinstance(term[0][0], float | int):
image = ImagePlot(
image=numpy.array(term),
label=name,
)
self._term_visualizers.append(image)
else:
carb.log_warn(
f"ManagerLiveVisualizer: Term ({name}) is not a supported data type for"
" visualization."
)
frame.collapsed = True

self._debug_vis = debug_vis
Expand Down

0 comments on commit 4fc4be5

Please sign in to comment.