Skip to content

Commit

Permalink
adds error to make sure we parsed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayankm96 committed Oct 7, 2024
1 parent 7365662 commit 4dea3be
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/extensions/omni.isaac.lab/omni/isaac/lab/envs/mdp/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def __init__(self, cfg: EventTermCfg, env: ManagerBasedEnv):
Args:
cfg: The configuration of the event term.
env: The environment instance.
Raises:
ValueError: If the asset is not a RigidObject or an Articulation.
"""
super().__init__(cfg, env)

Expand All @@ -86,6 +89,14 @@ def __init__(self, cfg: EventTermCfg, env: ManagerBasedEnv):
for link_path in self.asset.root_physx_view.link_paths[0]:
link_physx_view = self.asset._physics_sim_view.create_rigid_body_view(link_path) # type: ignore
self.num_shapes_per_body.append(link_physx_view.max_shapes)
# ensure the parsing is correct
num_shapes = sum(self.num_shapes_per_body)
expected_shapes = self.asset.root_physx_view.max_shapes
if num_shapes != expected_shapes:
raise ValueError(
"Randomization term 'randomize_rigid_body_material' failed to parse the number of shapes per body."
f" Expected total shapes: {expected_shapes}, but got: {num_shapes}."
)
else:
# in this case, we don't need to do special indexing
self.num_shapes_per_body = None
Expand Down

0 comments on commit 4dea3be

Please sign in to comment.