From 2b9fa6b82f95ad4b544baea64a410b50b131de7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cem=20G=C3=B6kmen?= Date: Fri, 7 Feb 2025 15:31:37 -0800 Subject: [PATCH] Standardize spelling of meta link --- omnigibson/object_states/attached_to.py | 6 +-- omnigibson/object_states/contains.py | 2 +- omnigibson/object_states/factory.py | 6 +-- .../object_states/heat_source_or_sink.py | 8 ++-- .../object_states/link_based_state_mixin.py | 38 +++++++++---------- omnigibson/object_states/on_fire.py | 4 +- omnigibson/object_states/particle_modifier.py | 20 +++++----- .../object_states/particle_source_or_sink.py | 16 ++++---- omnigibson/object_states/toggle.py | 2 +- omnigibson/objects/stateful_object.py | 8 ++-- omnigibson/utils/asset_utils.py | 14 +++---- omnigibson/utils/bddl_utils.py | 10 ++--- 12 files changed, 66 insertions(+), 68 deletions(-) diff --git a/omnigibson/object_states/attached_to.py b/omnigibson/object_states/attached_to.py index 30a7b35fbf..2e151d2910 100644 --- a/omnigibson/object_states/attached_to.py +++ b/omnigibson/object_states/attached_to.py @@ -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 @@ -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() diff --git a/omnigibson/object_states/contains.py b/omnigibson/object_states/contains.py index e95bb55d78..7a59218189 100644 --- a/omnigibson/object_states/contains.py +++ b/omnigibson/object_states/contains.py @@ -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): diff --git a/omnigibson/object_states/factory.py b/omnigibson/object_states/factory.py index 9df7c96ab9..0e58d8ac02 100644 --- a/omnigibson/object_states/factory.py +++ b/omnigibson/object_states/factory.py @@ -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 diff --git a/omnigibson/object_states/heat_source_or_sink.py b/omnigibson/object_states/heat_source_or_sink.py index 3644bfab1a..46ff1391fd 100644 --- a/omnigibson/object_states/heat_source_or_sink.py +++ b/omnigibson/object_states/heat_source_or_sink.py @@ -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 @@ -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 diff --git a/omnigibson/object_states/link_based_state_mixin.py b/omnigibson/object_states/link_based_state_mixin.py index abf59a8274..0dc1dae6bd 100644 --- a/omnigibson/object_states/link_based_state_mixin.py +++ b/omnigibson/object_states/link_based_state_mixin.py @@ -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(...)", ) @@ -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 @@ -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 @@ -103,7 +103,7 @@ 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 @@ -111,11 +111,9 @@ def _default_link(self): 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): diff --git a/omnigibson/object_states/on_fire.py b/omnigibson/object_states/on_fire.py index 65695f6b77..5d246fe0ad 100644 --- a/omnigibson/object_states/on_fire.py +++ b/omnigibson/object_states/on_fire.py @@ -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 diff --git a/omnigibson/object_states/particle_modifier.py b/omnigibson/object_states/particle_modifier.py index 053baf1b6d..6f016f2c5d 100644 --- a/omnigibson/object_states/particle_modifier.py +++ b/omnigibson/object_states/particle_modifier.py @@ -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 @@ -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 @@ -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: @@ -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 diff --git a/omnigibson/object_states/particle_source_or_sink.py b/omnigibson/object_states/particle_source_or_sink.py index e4ef621f0f..4c4bb09a1f 100644 --- a/omnigibson/object_states/particle_source_or_sink.py +++ b/omnigibson/object_states/particle_source_or_sink.py @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/omnigibson/object_states/toggle.py b/omnigibson/object_states/toggle.py index 297a37cae2..cc63a7e4c9 100644 --- a/omnigibson/object_states/toggle.py +++ b/omnigibson/object_states/toggle.py @@ -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): diff --git a/omnigibson/objects/stateful_object.py b/omnigibson/objects/stateful_object.py index 54e3ba96f7..3c0eef163a 100644 --- a/omnigibson/objects/stateful_object.py +++ b/omnigibson/objects/stateful_object.py @@ -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 @@ -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 @@ -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: diff --git a/omnigibson/utils/asset_utils.py b/omnigibson/utils/asset_utils.py index 37a1d41690..6ee0f6a481 100644 --- a/omnigibson/utils/asset_utils.py +++ b/omnigibson/utils/asset_utils.py @@ -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 @@ -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(): diff --git a/omnigibson/utils/bddl_utils.py b/omnigibson/utils/bddl_utils.py index 829916ca76..2fe6616321 100644 --- a/omnigibson/utils/bddl_utils.py +++ b/omnigibson/utils/bddl_utils.py @@ -21,7 +21,7 @@ from omnigibson.utils.asset_utils import ( get_all_object_categories, get_all_object_category_models_with_abilities, - get_attachment_metalinks, + get_attachment_meta_links, ) from omnigibson.utils.constants import PrimType from omnigibson.utils.python_utils import Wrapper @@ -1111,7 +1111,7 @@ def _consolidate_room_instance(self, filtered_object_scope, condition_type): def _filter_model_choices_by_attached_states(self, model_choices, category, obj_inst): # If obj_inst is a child object that depends on a parent object that has been imported or exists in the scene, - # we filter in only models that match the parent object's attachment metalinks. + # we filter in only models that match the parent object's attachment meta links. if obj_inst in self._attached_objects: parent_insts = self._attached_objects[obj_inst] parent_objects = [] @@ -1144,14 +1144,14 @@ def can_attach(child_attachment_links, parent_attachment_links): # Filter out models that don't support the attached states new_model_choices = set() for model_choice in model_choices: - child_attachment_links = get_attachment_metalinks(category, model_choice) + child_attachment_links = get_attachment_meta_links(category, model_choice) # The child model choice needs to be able to attach to all parent instances. # For in-room parent instances, there might be multiple parent objects (e.g. different wall nails), # and the child object needs to be able to attach to at least one of them. if all( any( can_attach( - child_attachment_links, get_attachment_metalinks(parent_obj.category, parent_obj.model) + child_attachment_links, get_attachment_meta_links(parent_obj.category, parent_obj.model) ) for parent_obj in parent_objs_per_inst ) @@ -1167,7 +1167,7 @@ def can_attach(child_attachment_links, parent_attachment_links): # Filter out models that don't support the attached states new_model_choices = set() for model_choice in model_choices: - if len(get_attachment_metalinks(category, model_choice)) > 0: + if len(get_attachment_meta_links(category, model_choice)) > 0: new_model_choices.add(model_choice) return new_model_choices