Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cgokmen committed Dec 15, 2023
1 parent 19b7689 commit 371496f
Show file tree
Hide file tree
Showing 5 changed files with 315 additions and 251 deletions.
22 changes: 10 additions & 12 deletions omnigibson/objects/object_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,26 @@ def _post_load(self):
scale = np.ones(3) if self._load_config["scale"] is None else np.array(self._load_config["scale"])
if self.n_joints == 0 and (np.all(np.isclose(scale, 1.0, atol=1e-3)) or self.n_fixed_joints == 0) and (self._load_config["kinematic_only"] != False):
kinematic_only = True
else:
# Create fixed joint, and set Body0 to be this object's root prim
create_joint(
prim_path=f"{self._prim_path}/rootJoint",
joint_type="FixedJoint",
body1=f"{self._prim_path}/{self._root_link_name}",
)

# Validate that we didn't make a kinematic-only decision that does not match
assert self._load_config["kinematic_only"] is None or kinematic_only == self._load_config["kinematic_only"], \
f"Kinematic only decision does not match! Got: {kinematic_only}, expected: {self._load_config['kinematic_only']}"

# Actually apply the kinematic-only decision
if kinematic_only:
for prim in self._prim.GetChildren():
if prim.GetPrimTypeInfo().GetTypeName() == "Xform":
prim.GetAttribute("physics:kinematicEnabled").Set(True)
prim.GetAttribute("physics:rigidBodyEnabled").Set(False)
self._load_config["kinematic_only"] = kinematic_only

# Run super first
super()._post_load()

# If the object is fixed_base but kinematic only is false, create the joint
if self.fixed_base and not self.kinematic_only:
# Create fixed joint, and set Body0 to be this object's root prim
create_joint(
prim_path=f"{self._prim_path}/rootJoint",
joint_type="FixedJoint",
body1=f"{self._prim_path}/{self._root_link_name}",
)

# Set visibility
if "visible" in self._load_config and self._load_config["visible"] is not None:
self.visible = self._load_config["visible"]
Expand Down
9 changes: 6 additions & 3 deletions omnigibson/prims/entity_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from omnigibson.prims.joint_prim import JointPrim
from omnigibson.prims.rigid_prim import RigidPrim
from omnigibson.prims.xform_prim import XFormPrim
from omnigibson.utils.extended_articulation_view import ExtendedArticulationView
from omnigibson.utils.deprecated_utils import ArticulationView
from omnigibson.utils.constants import PrimType, GEOM_TYPES, JointType, JointAxis
from omnigibson.utils.ui_utils import suppress_omni_log
from omnigibson.utils.usd_utils import BoundingBoxAPI
Expand Down Expand Up @@ -92,11 +92,14 @@ def _load(self):
def _post_load(self):
# Setup links info FIRST before running any other post loading behavior
# We pass in scale explicitly so that the generated links can leverage the desired entity scale
self.update_links(load_config=dict(scale=self._load_config.get("scale", None)))
self.update_links(load_config=dict(
scale=self._load_config.get("scale", None),
kinematic_only=self._load_config.get("kinematic_only", None)
))

# Prepare the articulation view.
if self.n_joints > 0:
self._articulation_view = ExtendedArticulationView(self._prim_path + "/base_link")
self._articulation_view = ArticulationView(self._prim_path + "/base_link")

# If this is a cloth, delete the root link and replace it with the single nested mesh
if self._prim_type == PrimType.CLOTH:
Expand Down
6 changes: 6 additions & 0 deletions omnigibson/prims/rigid_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class RigidPrim(XFormPrim):
density (None or float): If specified, density of this body in kg / m^3
visual_only (None or bool): If specified, whether this prim should include collisions or not.
Default is True.
kinematic_only (None or bool): If specified, whether this prim should be kinematic-only or not.
"""

def __init__(
Expand Down Expand Up @@ -80,6 +81,11 @@ def _post_load(self):
# Create the view
self._rigid_prim_view = RigidPrimView(self._prim_path)

# Set it to be kinematic if necessary
if "kinematic_only" in self._load_config and self._load_config["kinematic_only"]:
self.set_attribute("physics:kinematicEnabled", True)
self.set_attribute("physics:rigidBodyEnabled", False)

# run super first
super()._post_load()

Expand Down
Loading

0 comments on commit 371496f

Please sign in to comment.