Skip to content

Commit

Permalink
Standardize spelling of meta link
Browse files Browse the repository at this point in the history
  • Loading branch information
cgokmen committed Feb 7, 2025
1 parent b3a75a7 commit 2b9fa6b
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 68 deletions.
6 changes: 3 additions & 3 deletions omnigibson/object_states/attached_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def remove(self):
og.sim.remove_callback_on_stop(name=f"{self.obj.name}_detach")

@classproperty
def metalink_prefix(cls):
def meta_link_type(cls):
"""
Returns:
str: Unique keyword that defines the metalink associated with this object state
str: Unique keyword that defines the meta link associated with this object state
"""
return m.ATTACHMENT_LINK_PREFIX

Expand Down Expand Up @@ -375,7 +375,7 @@ def _disable_collision_between_child_and_parent(self, child, parent):
child_link.add_filtered_collision_pair(floor_link)

# Temporary hack to disable gravity for the attached child object if the parent is kinematic_only
# Otherwise, the parent metalink will oscillate due to the gravity force of the child.
# Otherwise, the parent meta link will oscillate due to the gravity force of the child.
if parent.kinematic_only:
child.disable_gravity()

Expand Down
2 changes: 1 addition & 1 deletion omnigibson/object_states/contains.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, obj):
self._compute_info = None # Intermediate computation information to store

@classproperty
def metalink_prefix(cls):
def meta_link_type(cls):
return m.CONTAINER_LINK_PREFIX

def _get_value(self, system):
Expand Down
6 changes: 3 additions & 3 deletions omnigibson/object_states/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ def get_states_by_dependency_order(states=None):
return list(reversed(list(nx.algorithms.topological_sort(get_state_dependency_graph(states)))))


# Define all metalinks
METALINK_PREFIXES = set()
# Define all meta links
META_LINK_TYPES = set()
for state in get_states_by_dependency_order():
if issubclass(state, LinkBasedStateMixin):
try:
METALINK_PREFIXES.add(state.metalink_prefix)
META_LINK_TYPES.add(state.meta_link_type)
except NotImplementedError:
pass
8 changes: 4 additions & 4 deletions omnigibson/object_states/heat_source_or_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ def is_compatible_asset(cls, prim, **kwargs):
return True, None

@classproperty
def metalink_prefix(cls):
def meta_link_type(cls):
return m.HEATSOURCE_LINK_PREFIX

@classmethod
def requires_metalink(cls, **kwargs):
# No metalink required if inside
def requires_meta_link(cls, **kwargs):
# No meta link required if inside
return not kwargs.get("requires_inside", False)

@property
Expand Down Expand Up @@ -251,7 +251,7 @@ def overlap_callback(hit):
affected_objects.remove(obj)

else:
# Position is either the AABB center of the default link or the metalink position itself
# Position is either the AABB center of the default link or the meta link position itself
heat_source_pos = (
self.link.aabb_center
if self.link == self._default_link
Expand Down
38 changes: 18 additions & 20 deletions omnigibson/object_states/link_based_state_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ def is_compatible(cls, obj, **kwargs):
if not compatible:
return compatible, reason

# Check whether this state requires metalink
if not cls.requires_metalink(**kwargs):
# Check whether this state requires meta link
if not cls.requires_meta_link(**kwargs):
return True, None
metalink_prefix = cls.metalink_prefix
meta_link_type = cls.meta_link_type
for link in obj.links.values():
if link.is_meta_link and link.meta_link_type == metalink_prefix:
if link.is_meta_link and link.meta_link_type == meta_link_type:
return True, None

return (
False,
f"LinkBasedStateMixin {cls.__name__} requires meta link with type {cls.metalink_prefix} "
f"LinkBasedStateMixin {cls.__name__} requires meta link with type {cls.meta_link_type} "
f"for obj {obj.name} but none was found! To get valid compatible object models, please use "
f"omnigibson.utils.asset_utils.get_all_object_category_models_with_abilities(...)",
)
Expand All @@ -44,38 +44,38 @@ def is_compatible_asset(cls, prim, **kwargs):
if not compatible:
return compatible, reason

# Check whether this state requires metalink
if not cls.requires_metalink(**kwargs):
# Check whether this state requires meta link
if not cls.requires_meta_link(**kwargs):
return True, None
metalink_prefix = cls.metalink_prefix
meta_link_type = cls.meta_link_type
for child in prim.GetChildren():
if child.GetTypeName() == "Xform":
if (
child.HasAttribute("ig:metaLinkType")
and child.GetAttribute("ig:metaLinkType").Get() == metalink_prefix
and child.GetAttribute("ig:metaLinkType").Get() == meta_link_type
):
return True, None

return (
False,
f"LinkBasedStateMixin {cls.__name__} requires meta link with prefix {cls.metalink_prefix} "
f"LinkBasedStateMixin {cls.__name__} requires meta link with prefix {cls.meta_link_type} "
f"for asset prim {prim.GetName()} but none was found! To get valid compatible object models, "
f"please use omnigibson.utils.asset_utils.get_all_object_category_models_with_abilities(...)",
)

@classproperty
def metalink_prefix(cls):
def meta_link_type(cls):
"""
Returns:
str: Unique keyword that defines the metalink associated with this object state
str: Unique keyword that defines the meta link associated with this object state
"""
NotImplementedError()

@classmethod
def requires_metalink(cls, **kwargs):
def requires_meta_link(cls, **kwargs):
"""
Returns:
Whether an object state instantiated with constructor arguments **kwargs will require a metalink
Whether an object state instantiated with constructor arguments **kwargs will require a meta link
or not
"""
# True by default
Expand All @@ -94,7 +94,7 @@ def link(self):
def links(self):
"""
Returns:
dict: mapping from link names to links that match the metalink_prefix
dict: mapping from link names to links that match the meta_link_type
"""
return self._links

Expand All @@ -103,19 +103,17 @@ def _default_link(self):
"""
Returns:
None or RigidPrim: If supported, the fallback link associated with this link-based state if
no valid metalink is found
no valid meta link is found
"""
# No default link by default
return None

def initialize_link_mixin(self):
assert not self._initialized

# TODO: Extend logic to account for multiple instances of the same metalink? e.g: _0, _1, ... suffixes
# TODO: Extend logic to account for multiple instances of the same meta link? e.g: _0, _1, ... suffixes
for name, link in self.obj.links.items():
if self.metalink_prefix in name or (
self._default_link is not None and link.name == self._default_link.name
):
if self.meta_link_type in name or (self._default_link is not None and link.name == self._default_link.name):
self._links[name] = link
# Make sure the scale is similar if the link is not a cloth prim
if not isinstance(link, ClothPrim):
Expand Down
4 changes: 2 additions & 2 deletions omnigibson/object_states/on_fire.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def __init__(
self.ignition_temperature = ignition_temperature

@classmethod
def requires_metalink(cls, **kwargs):
# Does not require metalink to be specified
def requires_meta_link(cls, **kwargs):
# Does not require meta link to be specified
return False

@property
Expand Down
20 changes: 10 additions & 10 deletions omnigibson/object_states/particle_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def overlap_callback(hit):
len(self.link.visual_meshes) == 1
), f"Expected only a single projection mesh for {self.link}, got: {len(self.link.visual_meshes)}"

# Make sure the mesh is translated so that its tip lies at the metalink origin, and rotated so the vector
# Make sure the mesh is translated so that its tip lies at the meta link origin, and rotated so the vector
# from tip to tail faces the positive x axis
z_offset = (
0.0
Expand Down Expand Up @@ -924,12 +924,12 @@ def requires_overlap(self):
return False

@classproperty
def metalink_prefix(cls):
def meta_link_type(cls):
return m.REMOVAL_LINK_PREFIX

@classmethod
def requires_metalink(cls, **kwargs):
# No metalink required for adjacency
def requires_meta_link(cls, **kwargs):
# No meta link required for adjacency
return kwargs.get("method", ParticleModifyMethod.ADJACENCY) != ParticleModifyMethod.ADJACENCY

@property
Expand Down Expand Up @@ -1088,15 +1088,15 @@ def _initialize(self):

# Make sure the meta mesh is aligned with the meta link if visualizing
# This corresponds to checking (a) position of tip of projection mesh should align with origin of
# metalink, and (b) zero relative orientation between the metalink and the projection mesh
# meta link, and (b) zero relative orientation between the meta link and the projection mesh
local_pos, local_quat = self.projection_mesh.get_position_orientation(frame="parent")
assert th.all(
th.isclose(local_pos + th.tensor([0, 0, height / 2.0]), th.zeros_like(local_pos))
), "Projection mesh tip should align with metalink position!"
), "Projection mesh tip should align with meta link position!"
local_euler = T.quat2euler(local_quat)
assert th.all(
th.isclose(local_euler, th.zeros_like(local_euler))
), "Projection mesh orientation should align with metalink orientation!"
), "Projection mesh orientation should align with meta link orientation!"

# Store which method to use for sampling particle locations
if self._sample_with_raycast:
Expand Down Expand Up @@ -1492,12 +1492,12 @@ def projection_is_active(self):
return self.projection_emitter.GetProperty("inputs:active").Get()

@classproperty
def metalink_prefix(cls):
def meta_link_type(cls):
return m.APPLICATION_LINK_PREFIX

@classmethod
def requires_metalink(cls, **kwargs):
# No metalink required for adjacency
def requires_meta_link(cls, **kwargs):
# No meta link required for adjacency
return kwargs.get("method", ParticleModifyMethod.ADJACENCY) != ParticleModifyMethod.ADJACENCY

@classmethod
Expand Down
16 changes: 8 additions & 8 deletions omnigibson/object_states/particle_source_or_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
class ParticleSource(ParticleApplier):
"""
ParticleApplier where physical particles are spawned continuously in a cylindrical fashion from the
metalink pose.
meta link pose.
Args:
obj (StatefulObject): Object to which this state will be applied
Expand Down Expand Up @@ -121,8 +121,8 @@ def _get_max_particles_limit_per_step(self, system):
return m.MAX_SOURCE_PARTICLES_PER_STEP

@classmethod
def requires_metalink(cls, **kwargs):
# Always requires metalink since projection is used
def requires_meta_link(cls, **kwargs):
# Always requires meta link since projection is used
return True

@property
Expand All @@ -131,7 +131,7 @@ def visualize(self):
return False

@classproperty
def metalink_prefix(cls):
def meta_link_type(cls):
return m.SOURCE_LINK_PREFIX

@property
Expand All @@ -146,7 +146,7 @@ def physical_particle_modification_limit(self):
class ParticleSink(ParticleRemover):
"""
ParticleRemover where physical particles are removed continuously within a cylindrical volume located
at the metalink pose.
at the meta link pose.
Args:
obj (StatefulObject): Object to which this state will be applied
Expand Down Expand Up @@ -235,12 +235,12 @@ def requires_overlap(self):
return False

@classmethod
def requires_metalink(cls, **kwargs):
# Always requires metalink since projection is used
def requires_meta_link(cls, **kwargs):
# Always requires meta link since projection is used
return True

@classproperty
def metalink_prefix(cls):
def meta_link_type(cls):
return m.SINK_LINK_PREFIX

@property
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/object_states/toggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def global_update(cls):
cls._finger_contact_objs.add(obj)

@classproperty
def metalink_prefix(cls):
def meta_link_type(cls):
return m.TOGGLE_LINK_PREFIX

def _get_value(self):
Expand Down
8 changes: 4 additions & 4 deletions omnigibson/objects/stateful_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ def _create_emitter_apis(self, emitter_type):
emitter_config = {}
bbox_extent_local = self.native_bbox if hasattr(self, "native_bbox") else self.aabb_extent / self.scale
if emitter_type == EmitterType.FIRE:
fire_at_metalink = True
fire_at_meta_link = True
if OnFire in self.states:
# Note whether the heat source link is explicitly set
link = self.states[OnFire].link
fire_at_metalink = link != self.root_link
fire_at_meta_link = link != self.root_link
elif HeatSourceOrSink in self.states:
# Only apply fire to non-root-link (i.e.: explicitly specified) heat source links
# Otherwise, immediately return
Expand All @@ -313,7 +313,7 @@ def _create_emitter_apis(self, emitter_type):
emitter_config["name"] = "flowEmitterSphere"
emitter_config["type"] = "FlowEmitterSphere"
emitter_config["position"] = (
(0.0, 0.0, 0.0) if fire_at_metalink else (0.0, 0.0, bbox_extent_local[2] * m.FIRE_EMITTER_HEIGHT_RATIO)
(0.0, 0.0, 0.0) if fire_at_meta_link else (0.0, 0.0, bbox_extent_local[2] * m.FIRE_EMITTER_HEIGHT_RATIO)
)
emitter_config["fuel"] = 0.6
emitter_config["coupleRateFuel"] = 1.2
Expand Down Expand Up @@ -391,7 +391,7 @@ def _create_emitter_apis(self, emitter_type):
if emitter_type == EmitterType.FIRE:
# Radius is in the absolute world coordinate even though the fire is under the link frame.
# In other words, scaling the object doesn't change the fire radius.
if fire_at_metalink:
if fire_at_meta_link:
# TODO: get radius of heat_source_link from metadata.
radius = 0.05
else:
Expand Down
14 changes: 7 additions & 7 deletions omnigibson/utils/asset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,16 @@ def supports_abilities(info, obj_prim):
return valid_models


def get_attachment_metalinks(category, model):
def get_attachment_meta_links(category, model):
"""
Get attachment metalinks for an object model
Get attachment meta links for an object model
Args:
category (str): Object category name
model (str): Object model name
Returns:
list of str: all attachment metalinks for the object model
list of str: all attachment meta links for the object model
"""
# Avoid circular imports
from omnigibson.object_states import AttachedTo
Expand All @@ -317,12 +317,12 @@ def get_attachment_metalinks(category, model):
with decrypted(usd_path) as fpath:
stage = lazy.pxr.Usd.Stage.Open(fpath)
prim = stage.GetDefaultPrim()
attachment_metalinks = []
attachment_meta_links = []
for child in prim.GetChildren():
if child.GetTypeName() == "Xform":
if AttachedTo.metalink_prefix in child.GetName():
attachment_metalinks.append(child.GetName())
return attachment_metalinks
if AttachedTo.meta_link_type in child.GetName():
attachment_meta_links.append(child.GetName())
return attachment_meta_links


def get_og_assets_version():
Expand Down
Loading

0 comments on commit 2b9fa6b

Please sign in to comment.