-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Prevent randomizing mass to zero or less #4060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Prevent randomizing mass to zero or less #4060
Conversation
Greptile OverviewGreptile SummaryAdded a single line of code to clamp randomized rigid body masses to a minimum value of 1e-6 kg in the Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant randomize_rigid_body_mass
participant _randomize_prop_by_op
participant PhysX
User->>randomize_rigid_body_mass: Call with mass_distribution_params
randomize_rigid_body_mass->>PhysX: Get current masses
randomize_rigid_body_mass->>randomize_rigid_body_mass: Reset to default_mass
randomize_rigid_body_mass->>_randomize_prop_by_op: Apply randomization (add/scale/abs)
_randomize_prop_by_op-->>randomize_rigid_body_mass: Return randomized masses
randomize_rigid_body_mass->>randomize_rigid_body_mass: Clamp masses to min=1e-6
Note over randomize_rigid_body_mass: Prevents zero/negative masses
randomize_rigid_body_mass->>PhysX: Set masses
alt recompute_inertia=True
randomize_rigid_body_mass->>randomize_rigid_body_mass: Calculate mass ratios
randomize_rigid_body_mass->>randomize_rigid_body_mass: Scale inertia tensors
randomize_rigid_body_mass->>PhysX: Set inertias
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, no comments
| masses = _randomize_prop_by_op( | ||
| masses, mass_distribution_params, env_ids, body_ids, operation=operation, distribution=distribution | ||
| ) | ||
| masses = torch.clamp(masses, min=1e-6) # ensure masses are positive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe good to have as an arg?
Description
This PR prevents users from accidentally randomizing the mass of rigid body to small and negative by clamping at 1e-6 kg.
Fixes #518
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there