Skip to content

Commit

Permalink
Merge pull request #636 from StanfordVL/sanity-check-transforms
Browse files Browse the repository at this point in the history
Require positive scales and validate local transforms
  • Loading branch information
cgokmen authored Apr 11, 2024
2 parents 9d36e24 + efa439b commit 496ad91
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions omnigibson/prims/xform_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ def set_position_orientation(self, position=None, orientation=None):
parent_world_transform = PoseAPI.get_world_pose_with_scale(parent_path)

local_transform = np.linalg.inv(parent_world_transform) @ my_world_transform
product = local_transform[:3, :3] @ local_transform[:3, :3].T
assert np.allclose(
product, np.diag(np.diag(product)), atol=1e-3
), f"{self.prim_path} local transform is not diagonal."
self.set_local_pose(*T.mat2pose(local_transform))

def get_position_orientation(self):
Expand Down Expand Up @@ -359,6 +363,7 @@ def scale(self, scale):
Defaults to None, which means left unchanged.
"""
scale = np.array(scale, dtype=float) if isinstance(scale, Iterable) else np.ones(3) * scale
assert np.all(scale > 0), f"Scale {scale} must consist of positive numbers."
scale = lazy.pxr.Gf.Vec3d(*scale)
properties = self.prim.GetPropertyNames()
if "xformOp:scale" not in properties:
Expand Down

0 comments on commit 496ad91

Please sign in to comment.