Skip to content

Commit

Permalink
adds find bodies for frame transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayankm96 committed Jan 30, 2025
1 parent 3a151ee commit 973b683
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
is_identity_pose,
subtract_frame_transforms,
)
import omni.isaac.lab.utils.string as string_utils

from ..sensor_base import SensorBase
from .frame_transformer_data import FrameTransformerData
Expand Down Expand Up @@ -88,6 +89,26 @@ def data(self) -> FrameTransformerData:
# return the data
return self._data

@property
def num_bodies(self) -> int:
"""Returns the number of target bodies being tracked.
Note:
This is an alias used for consistency with other sensors. Otherwise, we recommend using
:attr:`len(data.target_frame_names)` to access the number of target frames.
"""
return len(self._target_frame_body_names)

@property
def body_names(self) -> list[str]:
"""Returns the names of the target bodies being tracked.
Note:
This is an alias used for consistency with other sensors. Otherwise, we recommend using
:attr:`data.target_frame_names` to access the target frame names.
"""
return self._target_frame_body_names

"""
Operations
"""
Expand All @@ -99,6 +120,18 @@ def reset(self, env_ids: Sequence[int] | None = None):
if env_ids is None:
env_ids = ...

def find_bodies(self, name_keys: str | Sequence[str], preserve_order: bool = False) -> tuple[list[int], list[str]]:
"""Find bodies in the articulation based on the name keys.
Args:
name_keys: A regular expression or a list of regular expressions to match the body names.
preserve_order: Whether to preserve the order of the name keys in the output. Defaults to False.
Returns:
A tuple of lists containing the body indices and names.
"""
return string_utils.resolve_matching_names(name_keys, self._target_frame_names, preserve_order)

"""
Implementation.
"""
Expand Down

0 comments on commit 973b683

Please sign in to comment.