Skip to content

Commit 28f9c7c

Browse files
committed
add argument for minimum mass
1 parent 9777dbb commit 28f9c7c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

source/isaaclab/isaaclab/envs/mdp/events.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ def __init__(self, cfg: EventTermCfg, env: ManagerBasedEnv):
323323
"Randomization term 'randomize_rigid_body_mass' does not support operation:"
324324
f" '{cfg.params['operation']}'."
325325
)
326+
if cfg.params["min_mass"] < 1e-6:
327+
raise ValueError(
328+
"Randomization term 'randomize_rigid_body_mass' does not support 'min_mass' less than 1e-6 to avoid"
329+
" physics errors."
330+
)
326331

327332
def __call__(
328333
self,
@@ -333,6 +338,7 @@ def __call__(
333338
operation: Literal["add", "scale", "abs"],
334339
distribution: Literal["uniform", "log_uniform", "gaussian"] = "uniform",
335340
recompute_inertia: bool = True,
341+
min_mass: float = 1e-6,
336342
):
337343
# resolve environment ids
338344
if env_ids is None:
@@ -360,7 +366,7 @@ def __call__(
360366
masses = _randomize_prop_by_op(
361367
masses, mass_distribution_params, env_ids, body_ids, operation=operation, distribution=distribution
362368
)
363-
masses = torch.clamp(masses, min=1e-6) # ensure masses are positive
369+
masses = torch.clamp(masses, min=min_mass) # ensure masses are positive
364370

365371
# set the mass into the physics simulation
366372
self.asset.root_physx_view.set_masses(masses, env_ids)

0 commit comments

Comments
 (0)