Skip to content
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

fix cloth loading problems: caused by non-watertight, and potential multiple pieces #1063

Open
wants to merge 2 commits into
base: og-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions omnigibson/objects/dataset_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,6 @@ def __init__(
assert len(available_models) > 0, f"No available models found for category {category}!"
model = random.choice(available_models)

# If the model is in BAD_CLOTH_MODELS, raise an error for now -- this is a model that's unstable and needs to be fixed
# TODO: Remove this once the asset is fixed!
from omnigibson.utils.bddl_utils import BAD_CLOTH_MODELS

if prim_type == PrimType.CLOTH and model in BAD_CLOTH_MODELS.get(category, dict()):
raise ValueError(
f"Cannot create cloth object category: {category}, model: {model} because it is "
f"currently broken ): This will be fixed in the next release!"
)

self._model = model
usd_path = self.get_usd_path(category=category, model=model, dataset_type=dataset_type)

Expand Down
33 changes: 26 additions & 7 deletions omnigibson/systems/micro_particle_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@
# Create settings for this module
m = create_module_macros(module_path=__file__)


# TODO: Tune these default values!
# TODO (eric): figure out whether one offset can fit all
m.MAX_CLOTH_PARTICLES = 20000 # Comes from a limitation in physx - do not increase
m.CLOTH_PARTICLE_CONTACT_OFFSET = 0.0075
m.CLOTH_REMESHING_ERROR_THRESHOLD = 0.05
m.CLOTH_STRETCH_STIFFNESS = 10000.0
m.CLOTH_BEND_STIFFNESS = 200.0
m.CLOTH_SHEAR_STIFFNESS = 100.0
m.CLOTH_DAMPING = 0.2
m.CLOTH_STRETCH_STIFFNESS = 100.0
m.CLOTH_BEND_STIFFNESS = 50.0
m.CLOTH_SHEAR_STIFFNESS = 70.0
m.CLOTH_DAMPING = 0.02
m.CLOTH_FRICTION = 0.4
m.CLOTH_DRAG = 0.001
m.CLOTH_DRAG = 0.02
m.CLOTH_LIFT = 0.003
m.MIN_PARTICLE_CONTACT_OFFSET = 0.005 # Minimum particle contact offset for physical micro particles
m.FLUID_PARTICLE_PARTICLE_DISTANCE_SCALE = 0.8 # How much overlap expected between fluid particles at rest
Expand Down Expand Up @@ -1716,6 +1714,27 @@ def clothify_mesh_prim(self, mesh_prim, remesh=True, particle_distance=None):
ms.meshing_isotropic_explicit_remeshing(
iterations=5, adaptive=True, targetlen=pymeshlab.AbsoluteValue(particle_distance)
)
# Make sure the clothes is watertight
ms.meshing_repair_non_manifold_edges()
ms.meshing_repair_non_manifold_vertices()

# If the cloth has multiple pieces, only keep the largest one
ms.generate_splitting_by_connected_components(delete_source_mesh=True)
if len(ms) > 1:
log.warning(
f"The cloth mesh has {len(ms)} disconnected pieces. To simplify, we only keep the mesh with largest face number."
)
biggest_face_num = 0
for split_mesh in ms:
face_num = split_mesh.face_number()
if face_num > biggest_face_num:
biggest_face_num = face_num
new_ms = pymeshlab.MeshSet()
for split_mesh in ms:
if split_mesh.face_number() == biggest_face_num:
new_ms.add_mesh(split_mesh)
ms = new_ms

avg_edge_percentage_mismatch = abs(
1.0 - particle_distance / ms.get_geometric_measures()["avg_edge_length"]
)
Expand Down