warp-lang 1.9.1__py3-none-win_amd64.whl → 1.10.0rc2__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of warp-lang might be problematic. Click here for more details.
- warp/__init__.py +301 -287
- warp/__init__.pyi +794 -305
- warp/_src/__init__.py +14 -0
- warp/_src/autograd.py +1075 -0
- warp/_src/build.py +618 -0
- warp/_src/build_dll.py +640 -0
- warp/{builtins.py → _src/builtins.py} +1382 -377
- warp/_src/codegen.py +4359 -0
- warp/{config.py → _src/config.py} +178 -169
- warp/_src/constants.py +57 -0
- warp/_src/context.py +8294 -0
- warp/_src/dlpack.py +462 -0
- warp/_src/fabric.py +355 -0
- warp/_src/fem/__init__.py +14 -0
- warp/_src/fem/adaptivity.py +508 -0
- warp/_src/fem/cache.py +687 -0
- warp/_src/fem/dirichlet.py +188 -0
- warp/{fem → _src/fem}/domain.py +40 -30
- warp/_src/fem/field/__init__.py +131 -0
- warp/_src/fem/field/field.py +701 -0
- warp/{fem → _src/fem}/field/nodal_field.py +30 -15
- warp/{fem → _src/fem}/field/restriction.py +1 -1
- warp/{fem → _src/fem}/field/virtual.py +53 -27
- warp/_src/fem/geometry/__init__.py +32 -0
- warp/{fem → _src/fem}/geometry/adaptive_nanogrid.py +77 -163
- warp/_src/fem/geometry/closest_point.py +97 -0
- warp/{fem → _src/fem}/geometry/deformed_geometry.py +14 -22
- warp/{fem → _src/fem}/geometry/element.py +32 -10
- warp/{fem → _src/fem}/geometry/geometry.py +48 -20
- warp/{fem → _src/fem}/geometry/grid_2d.py +12 -23
- warp/{fem → _src/fem}/geometry/grid_3d.py +12 -23
- warp/{fem → _src/fem}/geometry/hexmesh.py +40 -63
- warp/{fem → _src/fem}/geometry/nanogrid.py +255 -248
- warp/{fem → _src/fem}/geometry/partition.py +121 -63
- warp/{fem → _src/fem}/geometry/quadmesh.py +26 -45
- warp/{fem → _src/fem}/geometry/tetmesh.py +40 -63
- warp/{fem → _src/fem}/geometry/trimesh.py +26 -45
- warp/{fem → _src/fem}/integrate.py +164 -158
- warp/_src/fem/linalg.py +383 -0
- warp/_src/fem/operator.py +396 -0
- warp/_src/fem/polynomial.py +229 -0
- warp/{fem → _src/fem}/quadrature/pic_quadrature.py +15 -20
- warp/{fem → _src/fem}/quadrature/quadrature.py +95 -47
- warp/_src/fem/space/__init__.py +248 -0
- warp/{fem → _src/fem}/space/basis_function_space.py +20 -11
- warp/_src/fem/space/basis_space.py +679 -0
- warp/{fem → _src/fem}/space/dof_mapper.py +3 -3
- warp/{fem → _src/fem}/space/function_space.py +14 -13
- warp/{fem → _src/fem}/space/grid_2d_function_space.py +4 -7
- warp/{fem → _src/fem}/space/grid_3d_function_space.py +4 -4
- warp/{fem → _src/fem}/space/hexmesh_function_space.py +4 -10
- warp/{fem → _src/fem}/space/nanogrid_function_space.py +3 -9
- warp/{fem → _src/fem}/space/partition.py +117 -60
- warp/{fem → _src/fem}/space/quadmesh_function_space.py +4 -10
- warp/{fem → _src/fem}/space/restriction.py +66 -33
- warp/_src/fem/space/shape/__init__.py +152 -0
- warp/{fem → _src/fem}/space/shape/cube_shape_function.py +9 -9
- warp/{fem → _src/fem}/space/shape/shape_function.py +8 -9
- warp/{fem → _src/fem}/space/shape/square_shape_function.py +6 -6
- warp/{fem → _src/fem}/space/shape/tet_shape_function.py +3 -3
- warp/{fem → _src/fem}/space/shape/triangle_shape_function.py +3 -3
- warp/{fem → _src/fem}/space/tetmesh_function_space.py +3 -9
- warp/_src/fem/space/topology.py +459 -0
- warp/{fem → _src/fem}/space/trimesh_function_space.py +3 -9
- warp/_src/fem/types.py +112 -0
- warp/_src/fem/utils.py +486 -0
- warp/_src/jax.py +186 -0
- warp/_src/jax_experimental/__init__.py +14 -0
- warp/_src/jax_experimental/custom_call.py +387 -0
- warp/_src/jax_experimental/ffi.py +1284 -0
- warp/_src/jax_experimental/xla_ffi.py +656 -0
- warp/_src/marching_cubes.py +708 -0
- warp/_src/math.py +414 -0
- warp/_src/optim/__init__.py +14 -0
- warp/_src/optim/adam.py +163 -0
- warp/_src/optim/linear.py +1606 -0
- warp/_src/optim/sgd.py +112 -0
- warp/_src/paddle.py +406 -0
- warp/_src/render/__init__.py +14 -0
- warp/_src/render/imgui_manager.py +289 -0
- warp/_src/render/render_opengl.py +3636 -0
- warp/_src/render/render_usd.py +937 -0
- warp/_src/render/utils.py +160 -0
- warp/_src/sparse.py +2716 -0
- warp/_src/tape.py +1206 -0
- warp/{thirdparty → _src/thirdparty}/unittest_parallel.py +9 -2
- warp/_src/torch.py +391 -0
- warp/_src/types.py +5870 -0
- warp/_src/utils.py +1693 -0
- warp/autograd.py +12 -1054
- warp/bin/warp-clang.dll +0 -0
- warp/bin/warp.dll +0 -0
- warp/build.py +8 -588
- warp/build_dll.py +6 -721
- warp/codegen.py +6 -4251
- warp/constants.py +6 -39
- warp/context.py +12 -8062
- warp/dlpack.py +6 -444
- warp/examples/distributed/example_jacobi_mpi.py +4 -5
- warp/examples/fem/example_adaptive_grid.py +1 -1
- warp/examples/fem/example_apic_fluid.py +1 -1
- warp/examples/fem/example_burgers.py +8 -8
- warp/examples/fem/example_diffusion.py +1 -1
- warp/examples/fem/example_distortion_energy.py +1 -1
- warp/examples/fem/example_mixed_elasticity.py +2 -2
- warp/examples/fem/example_navier_stokes.py +1 -1
- warp/examples/fem/example_nonconforming_contact.py +7 -7
- warp/examples/fem/example_stokes.py +1 -1
- warp/examples/fem/example_stokes_transfer.py +1 -1
- warp/examples/fem/utils.py +2 -2
- warp/examples/interop/example_jax_callable.py +1 -1
- warp/examples/interop/example_jax_ffi_callback.py +1 -1
- warp/examples/interop/example_jax_kernel.py +1 -1
- warp/examples/tile/example_tile_mcgp.py +191 -0
- warp/fabric.py +6 -337
- warp/fem/__init__.py +159 -97
- warp/fem/adaptivity.py +7 -489
- warp/fem/cache.py +9 -648
- warp/fem/dirichlet.py +6 -184
- warp/fem/field/__init__.py +8 -109
- warp/fem/field/field.py +7 -652
- warp/fem/geometry/__init__.py +7 -18
- warp/fem/geometry/closest_point.py +11 -77
- warp/fem/linalg.py +18 -366
- warp/fem/operator.py +11 -369
- warp/fem/polynomial.py +9 -209
- warp/fem/space/__init__.py +5 -211
- warp/fem/space/basis_space.py +6 -662
- warp/fem/space/shape/__init__.py +41 -118
- warp/fem/space/topology.py +6 -437
- warp/fem/types.py +6 -81
- warp/fem/utils.py +11 -444
- warp/jax.py +8 -165
- warp/jax_experimental/__init__.py +14 -1
- warp/jax_experimental/custom_call.py +8 -365
- warp/jax_experimental/ffi.py +17 -873
- warp/jax_experimental/xla_ffi.py +5 -605
- warp/marching_cubes.py +5 -689
- warp/math.py +16 -393
- warp/native/array.h +385 -37
- warp/native/builtin.h +314 -37
- warp/native/bvh.cpp +43 -9
- warp/native/bvh.cu +62 -27
- warp/native/bvh.h +310 -309
- warp/native/clang/clang.cpp +102 -97
- warp/native/coloring.cpp +0 -1
- warp/native/crt.h +208 -0
- warp/native/exports.h +156 -0
- warp/native/hashgrid.cu +2 -0
- warp/native/intersect.h +24 -1
- warp/native/intersect_tri.h +44 -35
- warp/native/mat.h +1456 -276
- warp/native/mesh.cpp +4 -4
- warp/native/mesh.cu +4 -2
- warp/native/mesh.h +176 -61
- warp/native/quat.h +0 -52
- warp/native/scan.cu +2 -0
- warp/native/sparse.cu +7 -3
- warp/native/spatial.h +12 -0
- warp/native/tile.h +681 -89
- warp/native/tile_radix_sort.h +1 -1
- warp/native/tile_reduce.h +394 -46
- warp/native/tile_scan.h +4 -4
- warp/native/vec.h +469 -0
- warp/native/version.h +23 -0
- warp/native/volume.cpp +1 -1
- warp/native/volume.cu +1 -0
- warp/native/volume.h +1 -1
- warp/native/volume_builder.cu +2 -0
- warp/native/warp.cpp +57 -29
- warp/native/warp.cu +253 -171
- warp/native/warp.h +11 -8
- warp/optim/__init__.py +6 -3
- warp/optim/adam.py +6 -145
- warp/optim/linear.py +14 -1585
- warp/optim/sgd.py +6 -94
- warp/paddle.py +6 -388
- warp/render/__init__.py +8 -4
- warp/render/imgui_manager.py +7 -267
- warp/render/render_opengl.py +6 -3618
- warp/render/render_usd.py +6 -919
- warp/render/utils.py +6 -142
- warp/sparse.py +37 -2563
- warp/tape.py +6 -1188
- warp/tests/__main__.py +1 -1
- warp/tests/cuda/test_async.py +4 -4
- warp/tests/cuda/test_conditional_captures.py +1 -1
- warp/tests/cuda/test_multigpu.py +1 -1
- warp/tests/cuda/test_streams.py +58 -1
- warp/tests/geometry/test_bvh.py +157 -22
- warp/tests/geometry/test_marching_cubes.py +0 -1
- warp/tests/geometry/test_mesh.py +5 -3
- warp/tests/geometry/test_mesh_query_aabb.py +5 -12
- warp/tests/geometry/test_mesh_query_point.py +5 -2
- warp/tests/geometry/test_mesh_query_ray.py +15 -3
- warp/tests/geometry/test_volume_write.py +5 -5
- warp/tests/interop/test_dlpack.py +14 -14
- warp/tests/interop/test_jax.py +772 -49
- warp/tests/interop/test_paddle.py +1 -1
- warp/tests/test_adam.py +0 -1
- warp/tests/test_arithmetic.py +9 -9
- warp/tests/test_array.py +527 -100
- warp/tests/test_array_reduce.py +3 -3
- warp/tests/test_atomic.py +12 -8
- warp/tests/test_atomic_bitwise.py +209 -0
- warp/tests/test_atomic_cas.py +4 -4
- warp/tests/test_bool.py +2 -2
- warp/tests/test_builtins_resolution.py +5 -571
- warp/tests/test_codegen.py +33 -14
- warp/tests/test_conditional.py +1 -1
- warp/tests/test_context.py +6 -6
- warp/tests/test_copy.py +242 -161
- warp/tests/test_ctypes.py +3 -3
- warp/tests/test_devices.py +24 -2
- warp/tests/test_examples.py +16 -84
- warp/tests/test_fabricarray.py +35 -35
- warp/tests/test_fast_math.py +0 -2
- warp/tests/test_fem.py +56 -10
- warp/tests/test_fixedarray.py +3 -3
- warp/tests/test_func.py +8 -5
- warp/tests/test_generics.py +1 -1
- warp/tests/test_indexedarray.py +24 -24
- warp/tests/test_intersect.py +39 -9
- warp/tests/test_large.py +1 -1
- warp/tests/test_lerp.py +3 -1
- warp/tests/test_linear_solvers.py +1 -1
- warp/tests/test_map.py +35 -4
- warp/tests/test_mat.py +52 -62
- warp/tests/test_mat_constructors.py +4 -5
- warp/tests/test_mat_lite.py +1 -1
- warp/tests/test_mat_scalar_ops.py +121 -121
- warp/tests/test_math.py +34 -0
- warp/tests/test_module_aot.py +4 -4
- warp/tests/test_modules_lite.py +28 -2
- warp/tests/test_print.py +11 -11
- warp/tests/test_quat.py +93 -58
- warp/tests/test_runlength_encode.py +1 -1
- warp/tests/test_scalar_ops.py +38 -10
- warp/tests/test_smoothstep.py +1 -1
- warp/tests/test_sparse.py +126 -15
- warp/tests/test_spatial.py +105 -87
- warp/tests/test_special_values.py +6 -6
- warp/tests/test_static.py +7 -7
- warp/tests/test_struct.py +13 -2
- warp/tests/test_triangle_closest_point.py +48 -1
- warp/tests/test_types.py +27 -15
- warp/tests/test_utils.py +52 -52
- warp/tests/test_vec.py +29 -29
- warp/tests/test_vec_constructors.py +5 -5
- warp/tests/test_vec_scalar_ops.py +97 -97
- warp/tests/test_version.py +75 -0
- warp/tests/tile/test_tile.py +178 -0
- warp/tests/tile/test_tile_atomic_bitwise.py +403 -0
- warp/tests/tile/test_tile_cholesky.py +7 -4
- warp/tests/tile/test_tile_load.py +26 -2
- warp/tests/tile/test_tile_mathdx.py +3 -3
- warp/tests/tile/test_tile_matmul.py +1 -1
- warp/tests/tile/test_tile_mlp.py +2 -4
- warp/tests/tile/test_tile_reduce.py +214 -13
- warp/tests/unittest_suites.py +6 -14
- warp/tests/unittest_utils.py +10 -9
- warp/tests/walkthrough_debug.py +3 -1
- warp/torch.py +6 -373
- warp/types.py +29 -5764
- warp/utils.py +10 -1659
- {warp_lang-1.9.1.dist-info → warp_lang-1.10.0rc2.dist-info}/METADATA +46 -99
- warp_lang-1.10.0rc2.dist-info/RECORD +468 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/Gaia-LICENSE.txt +6 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/appdirs-LICENSE.txt +22 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/asset_pixel_jpg-LICENSE.txt +3 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/cuda-LICENSE.txt +1582 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/dlpack-LICENSE.txt +201 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/fp16-LICENSE.txt +28 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/libmathdx-LICENSE.txt +220 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/llvm-LICENSE.txt +279 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/moller-LICENSE.txt +16 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/nanovdb-LICENSE.txt +2 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/nvrtc-LICENSE.txt +1592 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/svd-LICENSE.txt +23 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/unittest_parallel-LICENSE.txt +21 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/usd-LICENSE.txt +213 -0
- warp_lang-1.10.0rc2.dist-info/licenses/licenses/windingnumber-LICENSE.txt +21 -0
- warp/examples/assets/cartpole.urdf +0 -110
- warp/examples/assets/crazyflie.usd +0 -0
- warp/examples/assets/nv_ant.xml +0 -92
- warp/examples/assets/nv_humanoid.xml +0 -183
- warp/examples/assets/quadruped.urdf +0 -268
- warp/examples/optim/example_bounce.py +0 -266
- warp/examples/optim/example_cloth_throw.py +0 -228
- warp/examples/optim/example_drone.py +0 -870
- warp/examples/optim/example_inverse_kinematics.py +0 -182
- warp/examples/optim/example_inverse_kinematics_torch.py +0 -191
- warp/examples/optim/example_softbody_properties.py +0 -400
- warp/examples/optim/example_spring_cage.py +0 -245
- warp/examples/optim/example_trajectory.py +0 -227
- warp/examples/sim/example_cartpole.py +0 -143
- warp/examples/sim/example_cloth.py +0 -225
- warp/examples/sim/example_cloth_self_contact.py +0 -316
- warp/examples/sim/example_granular.py +0 -130
- warp/examples/sim/example_granular_collision_sdf.py +0 -202
- warp/examples/sim/example_jacobian_ik.py +0 -244
- warp/examples/sim/example_particle_chain.py +0 -124
- warp/examples/sim/example_quadruped.py +0 -203
- warp/examples/sim/example_rigid_chain.py +0 -203
- warp/examples/sim/example_rigid_contact.py +0 -195
- warp/examples/sim/example_rigid_force.py +0 -133
- warp/examples/sim/example_rigid_gyroscopic.py +0 -115
- warp/examples/sim/example_rigid_soft_contact.py +0 -140
- warp/examples/sim/example_soft_body.py +0 -196
- warp/examples/tile/example_tile_walker.py +0 -327
- warp/sim/__init__.py +0 -74
- warp/sim/articulation.py +0 -793
- warp/sim/collide.py +0 -2570
- warp/sim/graph_coloring.py +0 -307
- warp/sim/import_mjcf.py +0 -791
- warp/sim/import_snu.py +0 -227
- warp/sim/import_urdf.py +0 -579
- warp/sim/import_usd.py +0 -898
- warp/sim/inertia.py +0 -357
- warp/sim/integrator.py +0 -245
- warp/sim/integrator_euler.py +0 -2000
- warp/sim/integrator_featherstone.py +0 -2101
- warp/sim/integrator_vbd.py +0 -2487
- warp/sim/integrator_xpbd.py +0 -3295
- warp/sim/model.py +0 -4821
- warp/sim/particles.py +0 -121
- warp/sim/render.py +0 -431
- warp/sim/utils.py +0 -431
- warp/tests/sim/disabled_kinematics.py +0 -244
- warp/tests/sim/test_cloth.py +0 -863
- warp/tests/sim/test_collision.py +0 -743
- warp/tests/sim/test_coloring.py +0 -347
- warp/tests/sim/test_inertia.py +0 -161
- warp/tests/sim/test_model.py +0 -226
- warp/tests/sim/test_sim_grad.py +0 -287
- warp/tests/sim/test_sim_grad_bounce_linear.py +0 -212
- warp/tests/sim/test_sim_kinematics.py +0 -98
- warp/thirdparty/__init__.py +0 -0
- warp_lang-1.9.1.dist-info/RECORD +0 -456
- /warp/{fem → _src/fem}/quadrature/__init__.py +0 -0
- /warp/{tests/sim → _src/thirdparty}/__init__.py +0 -0
- /warp/{thirdparty → _src/thirdparty}/appdirs.py +0 -0
- /warp/{thirdparty → _src/thirdparty}/dlpack.py +0 -0
- {warp_lang-1.9.1.dist-info → warp_lang-1.10.0rc2.dist-info}/WHEEL +0 -0
- {warp_lang-1.9.1.dist-info → warp_lang-1.10.0rc2.dist-info}/licenses/LICENSE.md +0 -0
- {warp_lang-1.9.1.dist-info → warp_lang-1.10.0rc2.dist-info}/top_level.txt +0 -0
warp/tests/sim/test_cloth.py
DELETED
|
@@ -1,863 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
#
|
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
# you may not use this file except in compliance with the License.
|
|
6
|
-
# You may obtain a copy of the License at
|
|
7
|
-
#
|
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
#
|
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
# See the License for the specific language governing permissions and
|
|
14
|
-
# limitations under the License.
|
|
15
|
-
|
|
16
|
-
import unittest
|
|
17
|
-
from functools import partial
|
|
18
|
-
|
|
19
|
-
import numpy as np
|
|
20
|
-
|
|
21
|
-
import warp as wp
|
|
22
|
-
import warp.sim
|
|
23
|
-
import warp.sim.integrator
|
|
24
|
-
import warp.sim.integrator_euler
|
|
25
|
-
import warp.sim.integrator_vbd
|
|
26
|
-
import warp.sim.integrator_xpbd
|
|
27
|
-
import warp.sim.particles
|
|
28
|
-
import warp.sim.render
|
|
29
|
-
from warp.sim.model import PARTICLE_FLAG_ACTIVE
|
|
30
|
-
from warp.tests.unittest_utils import *
|
|
31
|
-
|
|
32
|
-
# fmt: off
|
|
33
|
-
CLOTH_POINTS = [
|
|
34
|
-
(-50.0000000, 0.0000000, -50.0000000),
|
|
35
|
-
(-38.8888893, 11.1111107, -50.0000000),
|
|
36
|
-
(-27.7777786, 22.2222214, -50.0000000),
|
|
37
|
-
(-16.6666679, 33.3333321, -50.0000000),
|
|
38
|
-
(-5.5555558, 44.4444427, -50.0000000),
|
|
39
|
-
(5.5555558, 55.5555573, -50.0000000),
|
|
40
|
-
(16.6666679, 66.6666641, -50.0000000),
|
|
41
|
-
(27.7777786, 77.7777786, -50.0000000),
|
|
42
|
-
(38.8888893, 88.8888855, -50.0000000),
|
|
43
|
-
(50.0000000, 100.0000000, -50.0000000),
|
|
44
|
-
(-50.0000000, 0.0000000, -38.8888893),
|
|
45
|
-
(-38.8888893, 11.1111107, -38.8888893),
|
|
46
|
-
(-27.7777786, 22.2222214, -38.8888893),
|
|
47
|
-
(-16.6666679, 33.3333321, -38.8888893),
|
|
48
|
-
(-5.5555558, 44.4444427, -38.8888893),
|
|
49
|
-
(5.5555558, 55.5555573, -38.8888893),
|
|
50
|
-
(16.6666679, 66.6666641, -38.8888893),
|
|
51
|
-
(27.7777786, 77.7777786, -38.8888893),
|
|
52
|
-
(38.8888893, 88.8888855, -38.8888893),
|
|
53
|
-
(50.0000000, 100.0000000, -38.8888893),
|
|
54
|
-
(-50.0000000, 0.0000000, -27.7777786),
|
|
55
|
-
(-38.8888893, 11.1111107, -27.7777786),
|
|
56
|
-
(-27.7777786, 22.2222214, -27.7777786),
|
|
57
|
-
(-16.6666679, 33.3333321, -27.7777786),
|
|
58
|
-
(-5.5555558, 44.4444427, -27.7777786),
|
|
59
|
-
(5.5555558, 55.5555573, -27.7777786),
|
|
60
|
-
(16.6666679, 66.6666641, -27.7777786),
|
|
61
|
-
(27.7777786, 77.7777786, -27.7777786),
|
|
62
|
-
(38.8888893, 88.8888855, -27.7777786),
|
|
63
|
-
(50.0000000, 100.0000000, -27.7777786),
|
|
64
|
-
(-50.0000000, 0.0000000, -16.6666679),
|
|
65
|
-
(-38.8888893, 11.1111107, -16.6666679),
|
|
66
|
-
(-27.7777786, 22.2222214, -16.6666679),
|
|
67
|
-
(-16.6666679, 33.3333321, -16.6666679),
|
|
68
|
-
(-5.5555558, 44.4444427, -16.6666679),
|
|
69
|
-
(5.5555558, 55.5555573, -16.6666679),
|
|
70
|
-
(16.6666679, 66.6666641, -16.6666679),
|
|
71
|
-
(27.7777786, 77.7777786, -16.6666679),
|
|
72
|
-
(38.8888893, 88.8888855, -16.6666679),
|
|
73
|
-
(50.0000000, 100.0000000, -16.6666679),
|
|
74
|
-
(-50.0000000, 0.0000000, -5.5555558),
|
|
75
|
-
(-38.8888893, 11.1111107, -5.5555558),
|
|
76
|
-
(-27.7777786, 22.2222214, -5.5555558),
|
|
77
|
-
(-16.6666679, 33.3333321, -5.5555558),
|
|
78
|
-
(-5.5555558, 44.4444427, -5.5555558),
|
|
79
|
-
(5.5555558, 55.5555573, -5.5555558),
|
|
80
|
-
(16.6666679, 66.6666641, -5.5555558),
|
|
81
|
-
(27.7777786, 77.7777786, -5.5555558),
|
|
82
|
-
(38.8888893, 88.8888855, -5.5555558),
|
|
83
|
-
(50.0000000, 100.0000000, -5.5555558),
|
|
84
|
-
(-50.0000000, 0.0000000, 5.5555558),
|
|
85
|
-
(-38.8888893, 11.1111107, 5.5555558),
|
|
86
|
-
(-27.7777786, 22.2222214, 5.5555558),
|
|
87
|
-
(-16.6666679, 33.3333321, 5.5555558),
|
|
88
|
-
(-5.5555558, 44.4444427, 5.5555558),
|
|
89
|
-
(5.5555558, 55.5555573, 5.5555558),
|
|
90
|
-
(16.6666679, 66.6666641, 5.5555558),
|
|
91
|
-
(27.7777786, 77.7777786, 5.5555558),
|
|
92
|
-
(38.8888893, 88.8888855, 5.5555558),
|
|
93
|
-
(50.0000000, 100.0000000, 5.5555558),
|
|
94
|
-
(-50.0000000, 0.0000000, 16.6666679),
|
|
95
|
-
(-38.8888893, 11.1111107, 16.6666679),
|
|
96
|
-
(-27.7777786, 22.2222214, 16.6666679),
|
|
97
|
-
(-16.6666679, 33.3333321, 16.6666679),
|
|
98
|
-
(-5.5555558, 44.4444427, 16.6666679),
|
|
99
|
-
(5.5555558, 55.5555573, 16.6666679),
|
|
100
|
-
(16.6666679, 66.6666641, 16.6666679),
|
|
101
|
-
(27.7777786, 77.7777786, 16.6666679),
|
|
102
|
-
(38.8888893, 88.8888855, 16.6666679),
|
|
103
|
-
(50.0000000, 100.0000000, 16.6666679),
|
|
104
|
-
(-50.0000000, 0.0000000, 27.7777786),
|
|
105
|
-
(-38.8888893, 11.1111107, 27.7777786),
|
|
106
|
-
(-27.7777786, 22.2222214, 27.7777786),
|
|
107
|
-
(-16.6666679, 33.3333321, 27.7777786),
|
|
108
|
-
(-5.5555558, 44.4444427, 27.7777786),
|
|
109
|
-
(5.5555558, 55.5555573, 27.7777786),
|
|
110
|
-
(16.6666679, 66.6666641, 27.7777786),
|
|
111
|
-
(27.7777786, 77.7777786, 27.7777786),
|
|
112
|
-
(38.8888893, 88.8888855, 27.7777786),
|
|
113
|
-
(50.0000000, 100.0000000, 27.7777786),
|
|
114
|
-
(-50.0000000, 0.0000000, 38.8888893),
|
|
115
|
-
(-38.8888893, 11.1111107, 38.8888893),
|
|
116
|
-
(-27.7777786, 22.2222214, 38.8888893),
|
|
117
|
-
(-16.6666679, 33.3333321, 38.8888893),
|
|
118
|
-
(-5.5555558, 44.4444427, 38.8888893),
|
|
119
|
-
(5.5555558, 55.5555573, 38.8888893),
|
|
120
|
-
(16.6666679, 66.6666641, 38.8888893),
|
|
121
|
-
(27.7777786, 77.7777786, 38.8888893),
|
|
122
|
-
(38.8888893, 88.8888855, 38.8888893),
|
|
123
|
-
(50.0000000, 100.0000000, 38.8888893),
|
|
124
|
-
(-50.0000000, 0.0000000, 50.0000000),
|
|
125
|
-
(-38.8888893, 11.1111107, 50.0000000),
|
|
126
|
-
(-27.7777786, 22.2222214, 50.0000000),
|
|
127
|
-
(-16.6666679, 33.3333321, 50.0000000),
|
|
128
|
-
(-5.5555558, 44.4444427, 50.0000000),
|
|
129
|
-
(5.5555558, 55.5555573, 50.0000000),
|
|
130
|
-
(16.6666679, 66.6666641, 50.0000000),
|
|
131
|
-
(27.7777786, 77.7777786, 50.0000000),
|
|
132
|
-
(38.8888893, 88.8888855, 50.0000000),
|
|
133
|
-
(50.0000000, 100.0000000, 50.0000000),
|
|
134
|
-
]
|
|
135
|
-
|
|
136
|
-
CLOTH_FACES = [
|
|
137
|
-
1, 12, 2,
|
|
138
|
-
1, 11, 12,
|
|
139
|
-
2, 12, 3,
|
|
140
|
-
12, 13, 3,
|
|
141
|
-
3, 14, 4,
|
|
142
|
-
3, 13, 14,
|
|
143
|
-
4, 14, 5,
|
|
144
|
-
14, 15, 5,
|
|
145
|
-
5, 16, 6,
|
|
146
|
-
5, 15, 16,
|
|
147
|
-
6, 16, 7,
|
|
148
|
-
16, 17, 7,
|
|
149
|
-
7, 18, 8,
|
|
150
|
-
7, 17, 18,
|
|
151
|
-
8, 18, 9,
|
|
152
|
-
18, 19, 9,
|
|
153
|
-
9, 20, 10,
|
|
154
|
-
9, 19, 20,
|
|
155
|
-
11, 21, 12,
|
|
156
|
-
21, 22, 12,
|
|
157
|
-
12, 23, 13,
|
|
158
|
-
12, 22, 23,
|
|
159
|
-
13, 23, 14,
|
|
160
|
-
23, 24, 14,
|
|
161
|
-
14, 25, 15,
|
|
162
|
-
14, 24, 25,
|
|
163
|
-
15, 25, 16,
|
|
164
|
-
25, 26, 16,
|
|
165
|
-
16, 27, 17,
|
|
166
|
-
16, 26, 27,
|
|
167
|
-
17, 27, 18,
|
|
168
|
-
27, 28, 18,
|
|
169
|
-
18, 29, 19,
|
|
170
|
-
18, 28, 29,
|
|
171
|
-
19, 29, 20,
|
|
172
|
-
29, 30, 20,
|
|
173
|
-
21, 32, 22,
|
|
174
|
-
21, 31, 32,
|
|
175
|
-
22, 32, 23,
|
|
176
|
-
32, 33, 23,
|
|
177
|
-
23, 34, 24,
|
|
178
|
-
23, 33, 34,
|
|
179
|
-
24, 34, 25,
|
|
180
|
-
34, 35, 25,
|
|
181
|
-
25, 36, 26,
|
|
182
|
-
25, 35, 36,
|
|
183
|
-
26, 36, 27,
|
|
184
|
-
36, 37, 27,
|
|
185
|
-
27, 38, 28,
|
|
186
|
-
27, 37, 38,
|
|
187
|
-
28, 38, 29,
|
|
188
|
-
38, 39, 29,
|
|
189
|
-
29, 40, 30,
|
|
190
|
-
29, 39, 40,
|
|
191
|
-
31, 41, 32,
|
|
192
|
-
41, 42, 32,
|
|
193
|
-
32, 43, 33,
|
|
194
|
-
32, 42, 43,
|
|
195
|
-
33, 43, 34,
|
|
196
|
-
43, 44, 34,
|
|
197
|
-
34, 45, 35,
|
|
198
|
-
34, 44, 45,
|
|
199
|
-
35, 45, 36,
|
|
200
|
-
45, 46, 36,
|
|
201
|
-
36, 47, 37,
|
|
202
|
-
36, 46, 47,
|
|
203
|
-
37, 47, 38,
|
|
204
|
-
47, 48, 38,
|
|
205
|
-
38, 49, 39,
|
|
206
|
-
38, 48, 49,
|
|
207
|
-
39, 49, 40,
|
|
208
|
-
49, 50, 40,
|
|
209
|
-
41, 52, 42,
|
|
210
|
-
41, 51, 52,
|
|
211
|
-
42, 52, 43,
|
|
212
|
-
52, 53, 43,
|
|
213
|
-
43, 54, 44,
|
|
214
|
-
43, 53, 54,
|
|
215
|
-
44, 54, 45,
|
|
216
|
-
54, 55, 45,
|
|
217
|
-
45, 56, 46,
|
|
218
|
-
45, 55, 56,
|
|
219
|
-
46, 56, 47,
|
|
220
|
-
56, 57, 47,
|
|
221
|
-
47, 58, 48,
|
|
222
|
-
47, 57, 58,
|
|
223
|
-
48, 58, 49,
|
|
224
|
-
58, 59, 49,
|
|
225
|
-
49, 60, 50,
|
|
226
|
-
49, 59, 60,
|
|
227
|
-
51, 61, 52,
|
|
228
|
-
61, 62, 52,
|
|
229
|
-
52, 63, 53,
|
|
230
|
-
52, 62, 63,
|
|
231
|
-
53, 63, 54,
|
|
232
|
-
63, 64, 54,
|
|
233
|
-
54, 65, 55,
|
|
234
|
-
54, 64, 65,
|
|
235
|
-
55, 65, 56,
|
|
236
|
-
65, 66, 56,
|
|
237
|
-
56, 67, 57,
|
|
238
|
-
56, 66, 67,
|
|
239
|
-
57, 67, 58,
|
|
240
|
-
67, 68, 58,
|
|
241
|
-
58, 69, 59,
|
|
242
|
-
58, 68, 69,
|
|
243
|
-
59, 69, 60,
|
|
244
|
-
69, 70, 60,
|
|
245
|
-
61, 72, 62,
|
|
246
|
-
61, 71, 72,
|
|
247
|
-
62, 72, 63,
|
|
248
|
-
72, 73, 63,
|
|
249
|
-
63, 74, 64,
|
|
250
|
-
63, 73, 74,
|
|
251
|
-
64, 74, 65,
|
|
252
|
-
74, 75, 65,
|
|
253
|
-
65, 76, 66,
|
|
254
|
-
65, 75, 76,
|
|
255
|
-
66, 76, 67,
|
|
256
|
-
76, 77, 67,
|
|
257
|
-
67, 78, 68,
|
|
258
|
-
67, 77, 78,
|
|
259
|
-
68, 78, 69,
|
|
260
|
-
78, 79, 69,
|
|
261
|
-
69, 80, 70,
|
|
262
|
-
69, 79, 80,
|
|
263
|
-
71, 81, 72,
|
|
264
|
-
81, 82, 72,
|
|
265
|
-
72, 83, 73,
|
|
266
|
-
72, 82, 83,
|
|
267
|
-
73, 83, 74,
|
|
268
|
-
83, 84, 74,
|
|
269
|
-
74, 85, 75,
|
|
270
|
-
74, 84, 85,
|
|
271
|
-
75, 85, 76,
|
|
272
|
-
85, 86, 76,
|
|
273
|
-
76, 87, 77,
|
|
274
|
-
76, 86, 87,
|
|
275
|
-
77, 87, 78,
|
|
276
|
-
87, 88, 78,
|
|
277
|
-
78, 89, 79,
|
|
278
|
-
78, 88, 89,
|
|
279
|
-
79, 89, 80,
|
|
280
|
-
89, 90, 80,
|
|
281
|
-
81, 92, 82,
|
|
282
|
-
81, 91, 92,
|
|
283
|
-
82, 92, 83,
|
|
284
|
-
92, 93, 83,
|
|
285
|
-
83, 94, 84,
|
|
286
|
-
83, 93, 94,
|
|
287
|
-
84, 94, 85,
|
|
288
|
-
94, 95, 85,
|
|
289
|
-
85, 96, 86,
|
|
290
|
-
85, 95, 96,
|
|
291
|
-
86, 96, 87,
|
|
292
|
-
96, 97, 87,
|
|
293
|
-
87, 98, 88,
|
|
294
|
-
87, 97, 98,
|
|
295
|
-
88, 98, 89,
|
|
296
|
-
98, 99, 89,
|
|
297
|
-
89, 100, 90,
|
|
298
|
-
89, 99, 100
|
|
299
|
-
]
|
|
300
|
-
|
|
301
|
-
# fmt: on
|
|
302
|
-
class ClothSim:
|
|
303
|
-
def __init__(self, device, solver, use_cuda_graph=False, do_rendering=False):
|
|
304
|
-
self.frame_dt = 1 / 60
|
|
305
|
-
self.num_test_frames = 50
|
|
306
|
-
self.iterations = 5
|
|
307
|
-
self.do_rendering = do_rendering
|
|
308
|
-
self.device = device
|
|
309
|
-
self.use_cuda_graph = self.device.is_cuda and use_cuda_graph
|
|
310
|
-
self.builder = wp.sim.ModelBuilder()
|
|
311
|
-
self.solver = solver
|
|
312
|
-
self.renderer_scale_factor = 1.0
|
|
313
|
-
|
|
314
|
-
if solver != "semi_implicit":
|
|
315
|
-
self.num_substeps = 10
|
|
316
|
-
else:
|
|
317
|
-
self.num_substeps = 32
|
|
318
|
-
self.dt = self.frame_dt / self.num_substeps
|
|
319
|
-
|
|
320
|
-
def set_up_sagging_experiment(self):
|
|
321
|
-
self.input_scale_factor = 1.0
|
|
322
|
-
self.renderer_scale_factor = 0.01
|
|
323
|
-
vertices = [wp.vec3(v) * self.input_scale_factor for v in CLOTH_POINTS]
|
|
324
|
-
faces_flatten = [fv - 1 for fv in CLOTH_FACES]
|
|
325
|
-
|
|
326
|
-
kd = 1.0e-7
|
|
327
|
-
|
|
328
|
-
if self.solver != "semi_implicit":
|
|
329
|
-
stretching_stiffness = 1e4
|
|
330
|
-
spring_ke = 1e3
|
|
331
|
-
bending_ke = 10
|
|
332
|
-
else:
|
|
333
|
-
stretching_stiffness = 1e5
|
|
334
|
-
spring_ke = 1e2
|
|
335
|
-
bending_ke = 0.0
|
|
336
|
-
|
|
337
|
-
self.builder.add_cloth_mesh(
|
|
338
|
-
pos=wp.vec3(0.0, 0.0, 0.0),
|
|
339
|
-
rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
|
|
340
|
-
scale=1.0,
|
|
341
|
-
vertices=vertices,
|
|
342
|
-
indices=faces_flatten,
|
|
343
|
-
vel=wp.vec3(0.0, 0.0, 0.0),
|
|
344
|
-
density=0.1,
|
|
345
|
-
tri_ke=stretching_stiffness,
|
|
346
|
-
tri_ka=stretching_stiffness,
|
|
347
|
-
tri_kd=kd,
|
|
348
|
-
edge_ke=bending_ke,
|
|
349
|
-
add_springs=self.solver == "xpbd",
|
|
350
|
-
spring_ke=spring_ke,
|
|
351
|
-
spring_kd=0.0,
|
|
352
|
-
)
|
|
353
|
-
|
|
354
|
-
self.fixed_particles = [0, 9]
|
|
355
|
-
|
|
356
|
-
self.finalize(ground=False)
|
|
357
|
-
|
|
358
|
-
self.state1.particle_q.fill_(0.0)
|
|
359
|
-
|
|
360
|
-
def set_up_bending_experiment(self):
|
|
361
|
-
stretching_stiffness = 1e4
|
|
362
|
-
stretching_damping = 1e-6
|
|
363
|
-
bending_damping = 1e-3
|
|
364
|
-
# fmt: off
|
|
365
|
-
vs = [[-6.0, 0.0, -6.0], [-3.6, 0.0, -6.0], [-1.2, 0.0, -6.0], [1.2, 0.0, -6.0], [3.6, 0.0, -6.0], [6.0, 0.0, -6.0],
|
|
366
|
-
[-6.0, 0.0, -3.6], [-3.6, 0.0, -3.6], [-1.2, 0.0, -3.6], [1.2, 0.0, -3.6], [3.6, 0.0, -3.6], [6.0, 0.0, -3.6],
|
|
367
|
-
[-6.0, 0.0, -1.2], [-3.6, 0.0, -1.2], [-1.2, 0.0, -1.2], [1.2, 0.0, -1.2], [3.6, 0.0, -1.2], [6.0, 0.0, -1.2],
|
|
368
|
-
[-6.0, 0.0, 1.2], [-3.6, 0.0, 1.2], [-1.2, 0.0, 1.2], [1.2, 0.0, 1.2], [3.6, 0.0, 1.2], [6.0, 0.0, 1.2],
|
|
369
|
-
[-6.0, 0.0, 3.6], [-3.6, 0.0, 3.6], [-1.2, 0.0, 3.6], [1.2, 0.0, 3.6], [3.6, 0.0, 3.6], [6.0, 0.0, 3.6],
|
|
370
|
-
[-6.0, 0.0, 6.0], [-3.6, 0.0, 6.0], [-1.2, 0.0, 6.0], [1.2, 0.0, 6.0], [3.6, 0.0, 6.0], [6.0, 0.0, 6.0]]
|
|
371
|
-
|
|
372
|
-
fs = [0, 7, 1, 0, 6, 7, 1, 7, 2, 7, 8, 2, 2, 9, 3, 2, 8, 9, 3, 9, 4, 9, 10, 4, 4, 11, 5, 4, 10, 11, 6, 12, 7, 12, 13,
|
|
373
|
-
7, 7, 14, 8, 7, 13, 14, 8, 14, 9, 14, 15, 9, 9, 16, 10, 9, 15, 16, 10, 16, 11, 16, 17, 11, 12, 19, 13, 12, 18,
|
|
374
|
-
19, 13, 19, 14, 19, 20, 14, 14, 21, 15, 14, 20, 21, 15, 21, 16, 21, 22, 16, 16, 23, 17, 16, 22, 23, 18, 24, 19,
|
|
375
|
-
24, 25, 19, 19, 26, 20, 19, 25, 26, 20, 26, 21, 26, 27, 21, 21, 28, 22, 21, 27, 28, 22, 28, 23, 28, 29, 23, 24,
|
|
376
|
-
31, 25, 24, 30, 31, 25, 31, 26, 31, 32, 26, 26, 33, 27, 26, 32, 33, 27, 33, 28, 33, 34, 28, 28, 35, 29, 28, 34,
|
|
377
|
-
35]
|
|
378
|
-
# fmt: on
|
|
379
|
-
|
|
380
|
-
vs = [wp.vec3(v) for v in vs]
|
|
381
|
-
|
|
382
|
-
self.builder.add_cloth_mesh(
|
|
383
|
-
pos=wp.vec3(0.0, 10.0, 0.0),
|
|
384
|
-
rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
|
|
385
|
-
scale=1.0,
|
|
386
|
-
vertices=vs,
|
|
387
|
-
indices=fs,
|
|
388
|
-
vel=wp.vec3(0.0, 0.0, 0.0),
|
|
389
|
-
density=0.02,
|
|
390
|
-
tri_ke=stretching_stiffness,
|
|
391
|
-
tri_ka=stretching_stiffness,
|
|
392
|
-
tri_kd=stretching_damping,
|
|
393
|
-
edge_ke=10,
|
|
394
|
-
edge_kd=bending_damping,
|
|
395
|
-
add_springs=self.solver == "xpbd",
|
|
396
|
-
spring_ke=1.0e3,
|
|
397
|
-
spring_kd=0.0,
|
|
398
|
-
)
|
|
399
|
-
|
|
400
|
-
self.builder.add_cloth_mesh(
|
|
401
|
-
pos=wp.vec3(15.0, 10.0, 0.0),
|
|
402
|
-
rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
|
|
403
|
-
scale=1.0,
|
|
404
|
-
vertices=vs,
|
|
405
|
-
indices=fs,
|
|
406
|
-
vel=wp.vec3(0.0, 0.0, 0.0),
|
|
407
|
-
density=0.02,
|
|
408
|
-
tri_ke=stretching_stiffness,
|
|
409
|
-
tri_ka=stretching_stiffness,
|
|
410
|
-
tri_kd=stretching_damping,
|
|
411
|
-
edge_ke=100,
|
|
412
|
-
edge_kd=bending_damping,
|
|
413
|
-
add_springs=self.solver == "xpbd",
|
|
414
|
-
spring_ke=1.0e3,
|
|
415
|
-
spring_kd=0.0,
|
|
416
|
-
)
|
|
417
|
-
|
|
418
|
-
self.builder.add_cloth_mesh(
|
|
419
|
-
pos=wp.vec3(30.0, 10.0, 0.0),
|
|
420
|
-
rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
|
|
421
|
-
scale=1.0,
|
|
422
|
-
vertices=vs,
|
|
423
|
-
indices=fs,
|
|
424
|
-
vel=wp.vec3(0.0, 0.0, 0.0),
|
|
425
|
-
density=0.02,
|
|
426
|
-
tri_ke=stretching_stiffness,
|
|
427
|
-
tri_ka=stretching_stiffness,
|
|
428
|
-
tri_kd=stretching_damping,
|
|
429
|
-
edge_ke=1000,
|
|
430
|
-
edge_kd=bending_damping,
|
|
431
|
-
add_springs=self.solver == "xpbd",
|
|
432
|
-
spring_ke=1.0e3,
|
|
433
|
-
spring_kd=0.0,
|
|
434
|
-
)
|
|
435
|
-
|
|
436
|
-
self.fixed_particles = [0, 29, 36, 65, 72, 101]
|
|
437
|
-
|
|
438
|
-
self.finalize()
|
|
439
|
-
|
|
440
|
-
def set_self_collision_experiment(self):
|
|
441
|
-
elasticity_ke = 1e4
|
|
442
|
-
elasticity_kd = 1e-6
|
|
443
|
-
|
|
444
|
-
vs1 = [wp.vec3(v) for v in [[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1]]]
|
|
445
|
-
fs1 = [0, 1, 2, 0, 2, 3]
|
|
446
|
-
|
|
447
|
-
self.builder.add_cloth_mesh(
|
|
448
|
-
pos=wp.vec3(0.0, 0.0, 0.0),
|
|
449
|
-
rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
|
|
450
|
-
scale=1.0,
|
|
451
|
-
vertices=vs1,
|
|
452
|
-
indices=fs1,
|
|
453
|
-
vel=wp.vec3(0.0, 0.0, 0.0),
|
|
454
|
-
density=0.02,
|
|
455
|
-
tri_ke=elasticity_ke,
|
|
456
|
-
tri_ka=elasticity_ke,
|
|
457
|
-
tri_kd=elasticity_kd,
|
|
458
|
-
add_springs=self.solver == "xpbd",
|
|
459
|
-
spring_ke=1.0e3,
|
|
460
|
-
spring_kd=0.0,
|
|
461
|
-
)
|
|
462
|
-
|
|
463
|
-
vs2 = [wp.vec3(v) for v in [[0.3, 0, 0.7], [0.3, 0, 0.2], [0.8, 0, 0.4]]]
|
|
464
|
-
fs2 = [0, 1, 2]
|
|
465
|
-
|
|
466
|
-
self.builder.add_cloth_mesh(
|
|
467
|
-
pos=wp.vec3(0.0, 0.5, 0.0),
|
|
468
|
-
rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
|
|
469
|
-
scale=1.0,
|
|
470
|
-
vertices=vs2,
|
|
471
|
-
indices=fs2,
|
|
472
|
-
vel=wp.vec3(0.0, 0.0, 0.0),
|
|
473
|
-
density=0.02,
|
|
474
|
-
tri_ke=elasticity_ke,
|
|
475
|
-
tri_ka=elasticity_ke,
|
|
476
|
-
tri_kd=elasticity_kd,
|
|
477
|
-
add_springs=self.solver == "xpbd",
|
|
478
|
-
spring_ke=1.0e3,
|
|
479
|
-
spring_kd=0.0,
|
|
480
|
-
)
|
|
481
|
-
|
|
482
|
-
self.fixed_particles = range(0, 4)
|
|
483
|
-
|
|
484
|
-
self.finalize(handle_self_contact=True, ground=False)
|
|
485
|
-
self.model.soft_contact_radius = 0.1
|
|
486
|
-
self.model.soft_contact_margin = 0.1
|
|
487
|
-
self.model.soft_contact_ke = 1e4
|
|
488
|
-
self.model.soft_contact_kd = 1e-3
|
|
489
|
-
self.model.soft_contact_mu = 0.2
|
|
490
|
-
self.model.gravity = wp.vec3(0.0, -1000.0, 0)
|
|
491
|
-
self.num_test_frames = 30
|
|
492
|
-
|
|
493
|
-
def set_body_collision_experiment(self, handle_self_contact=False):
|
|
494
|
-
self.renderer_scale_factor = 1.0
|
|
495
|
-
elasticity_ke = 1e4
|
|
496
|
-
elasticity_kd = 1e-6
|
|
497
|
-
|
|
498
|
-
vs1 = [wp.vec3(v) for v in [[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1]]]
|
|
499
|
-
fs1 = [0, 1, 2, 0, 2, 3]
|
|
500
|
-
|
|
501
|
-
self.builder.add_cloth_mesh(
|
|
502
|
-
pos=wp.vec3(0.0, 0.0, 0.0),
|
|
503
|
-
rot=wp.quat_from_axis_angle(wp.vec3(1.0, 0.0, 0.0), 0.0),
|
|
504
|
-
scale=1.0,
|
|
505
|
-
vertices=vs1,
|
|
506
|
-
indices=fs1,
|
|
507
|
-
vel=wp.vec3(0.0, 0.0, 0.0),
|
|
508
|
-
density=0.02,
|
|
509
|
-
tri_ke=elasticity_ke,
|
|
510
|
-
tri_ka=elasticity_ke,
|
|
511
|
-
tri_kd=elasticity_kd,
|
|
512
|
-
add_springs=self.solver == "xpbd",
|
|
513
|
-
spring_ke=1.0e3,
|
|
514
|
-
spring_kd=0.0,
|
|
515
|
-
particle_radius=0.1,
|
|
516
|
-
)
|
|
517
|
-
|
|
518
|
-
self.builder.add_shape_box(-1, pos=wp.vec3(0, -3.3, 0), hx=3, hy=3, hz=3)
|
|
519
|
-
|
|
520
|
-
self.fixed_particles = []
|
|
521
|
-
|
|
522
|
-
self.finalize(handle_self_contact=handle_self_contact, ground=False)
|
|
523
|
-
self.model.soft_contact_radius = 0.1
|
|
524
|
-
self.model.soft_contact_margin = 0.1
|
|
525
|
-
self.model.soft_contact_ke = 1e4
|
|
526
|
-
self.model.soft_contact_kd = 1e-3
|
|
527
|
-
self.model.soft_contact_mu = 0.2
|
|
528
|
-
self.model.gravity = wp.vec3(0.0, -1000.0, 0)
|
|
529
|
-
self.num_test_frames = 30
|
|
530
|
-
|
|
531
|
-
def set_up_non_zero_rest_angle_bending_experiment(self):
|
|
532
|
-
# fmt: off
|
|
533
|
-
vs =[
|
|
534
|
-
[ 0. , 1. , -1. ],
|
|
535
|
-
[ 0. , 1. , 1. ],
|
|
536
|
-
[ 0.70711, 0.70711, -1. ],
|
|
537
|
-
[ 0.70711, 0.70711, 1. ],
|
|
538
|
-
[ 1. , 0. , -1. ],
|
|
539
|
-
[ 1. , -0. , 1. ],
|
|
540
|
-
[ 0.70711, -0.70711, -1. ],
|
|
541
|
-
[ 0.70711, -0.70711, 1. ],
|
|
542
|
-
[ 0. , -1. , -1. ],
|
|
543
|
-
[ 0. , -1. , 1. ],
|
|
544
|
-
[-0.70711, -0.70711, -1. ],
|
|
545
|
-
[-0.70711, -0.70711, 1. ],
|
|
546
|
-
[-1. , 0. , -1. ],
|
|
547
|
-
[-1. , -0. , 1. ],
|
|
548
|
-
[-0.70711, 0.70711, -1. ],
|
|
549
|
-
[-0.70711, 0.70711, 1. ],
|
|
550
|
-
]
|
|
551
|
-
fs = [
|
|
552
|
-
1, 2, 0,
|
|
553
|
-
3, 4, 2,
|
|
554
|
-
5, 6, 4,
|
|
555
|
-
7, 8, 6,
|
|
556
|
-
9, 10, 8,
|
|
557
|
-
11, 12, 10,
|
|
558
|
-
3, 5, 4,
|
|
559
|
-
13, 14, 12,
|
|
560
|
-
15, 0, 14,
|
|
561
|
-
1, 3, 2,
|
|
562
|
-
5, 7, 6,
|
|
563
|
-
7, 9, 8,
|
|
564
|
-
9, 11, 10,
|
|
565
|
-
11, 13, 12,
|
|
566
|
-
13, 15, 14,
|
|
567
|
-
15, 1, 0,
|
|
568
|
-
]
|
|
569
|
-
# fmt: on
|
|
570
|
-
|
|
571
|
-
stretching_stiffness = 1e5
|
|
572
|
-
stretching_damping = 1e-5
|
|
573
|
-
edge_ke = 100
|
|
574
|
-
bending_damping = 1e-4
|
|
575
|
-
vs = [wp.vec3(v) for v in vs]
|
|
576
|
-
|
|
577
|
-
self.builder.add_cloth_mesh(
|
|
578
|
-
pos=wp.vec3(0.0, 0.0, 0.0),
|
|
579
|
-
rot=wp.quat_identity(),
|
|
580
|
-
scale=1.0,
|
|
581
|
-
vertices=vs,
|
|
582
|
-
indices=fs,
|
|
583
|
-
vel=wp.vec3(0.0, 0.0, 0.0),
|
|
584
|
-
density=0.02,
|
|
585
|
-
tri_ke=stretching_stiffness,
|
|
586
|
-
tri_ka=stretching_stiffness,
|
|
587
|
-
tri_kd=stretching_damping,
|
|
588
|
-
edge_ke=edge_ke,
|
|
589
|
-
edge_kd=bending_damping,
|
|
590
|
-
add_springs=self.solver == "xpbd",
|
|
591
|
-
spring_ke=1.0e3,
|
|
592
|
-
spring_kd=0.0,
|
|
593
|
-
)
|
|
594
|
-
self.fixed_particles = [0, 1]
|
|
595
|
-
|
|
596
|
-
self.finalize(handle_self_contact=False, ground=False)
|
|
597
|
-
|
|
598
|
-
def set_free_falling_experiment(self):
|
|
599
|
-
self.input_scale_factor = 1.0
|
|
600
|
-
self.renderer_scale_factor = 0.01
|
|
601
|
-
vertices = [wp.vec3(v) * self.input_scale_factor for v in CLOTH_POINTS]
|
|
602
|
-
faces_flatten = [fv - 1 for fv in CLOTH_FACES]
|
|
603
|
-
if self.solver != "semi_implicit":
|
|
604
|
-
stretching_stiffness = 1e4
|
|
605
|
-
spring_ke = 1e3
|
|
606
|
-
bending_ke = 10
|
|
607
|
-
else:
|
|
608
|
-
stretching_stiffness = 1e2
|
|
609
|
-
spring_ke = 1e2
|
|
610
|
-
bending_ke = 10
|
|
611
|
-
|
|
612
|
-
self.builder.add_cloth_mesh(
|
|
613
|
-
vertices=vertices,
|
|
614
|
-
indices=faces_flatten,
|
|
615
|
-
scale=0.1,
|
|
616
|
-
density=2,
|
|
617
|
-
pos=wp.vec3(0.0, 4.0, 0.0),
|
|
618
|
-
rot=wp.quat_identity(),
|
|
619
|
-
vel=wp.vec3(0.0, 0.0, 0.0),
|
|
620
|
-
edge_ke=bending_ke,
|
|
621
|
-
edge_kd=0.0,
|
|
622
|
-
tri_ke=stretching_stiffness,
|
|
623
|
-
tri_ka=stretching_stiffness,
|
|
624
|
-
tri_kd=0.0,
|
|
625
|
-
add_springs=self.solver == "xpbd",
|
|
626
|
-
spring_ke=spring_ke,
|
|
627
|
-
spring_kd=0.0,
|
|
628
|
-
)
|
|
629
|
-
self.fixed_particles = []
|
|
630
|
-
self.num_test_frames = 30
|
|
631
|
-
self.finalize(ground=False)
|
|
632
|
-
|
|
633
|
-
def finalize(self, handle_self_contact=False, ground=True):
|
|
634
|
-
self.builder.color(include_bending=True)
|
|
635
|
-
|
|
636
|
-
self.model = self.builder.finalize(device=self.device)
|
|
637
|
-
self.model.ground = ground
|
|
638
|
-
self.model.gravity = wp.vec3(0, -1000.0, 0)
|
|
639
|
-
self.model.soft_contact_ke = 1.0e4
|
|
640
|
-
self.model.soft_contact_kd = 1.0e-2
|
|
641
|
-
|
|
642
|
-
self.set_points_fixed(self.model, self.fixed_particles)
|
|
643
|
-
|
|
644
|
-
if self.solver == "vbd":
|
|
645
|
-
self.integrator = wp.sim.VBDIntegrator(self.model, self.iterations, handle_self_contact=handle_self_contact)
|
|
646
|
-
elif self.solver == "xpbd":
|
|
647
|
-
self.integrator = wp.sim.XPBDIntegrator(
|
|
648
|
-
self.iterations,
|
|
649
|
-
)
|
|
650
|
-
elif self.solver == "semi_implicit":
|
|
651
|
-
self.integrator = wp.sim.SemiImplicitIntegrator()
|
|
652
|
-
else:
|
|
653
|
-
raise ValueError("Unsupported solver type: " + self.solver)
|
|
654
|
-
|
|
655
|
-
self.state0 = self.model.state()
|
|
656
|
-
self.state1 = self.model.state()
|
|
657
|
-
|
|
658
|
-
self.init_pos = np.array(self.state0.particle_q.numpy(), copy=True)
|
|
659
|
-
|
|
660
|
-
self.graph = None
|
|
661
|
-
if self.use_cuda_graph:
|
|
662
|
-
if self.solver == "vbd":
|
|
663
|
-
wp.set_module_options({"block_dim": 256}, warp.sim.integrator_vbd)
|
|
664
|
-
wp.load_module(warp.sim.integrator_vbd, device=self.device)
|
|
665
|
-
elif self.solver == "xpbd":
|
|
666
|
-
wp.set_module_options({"block_dim": 256}, warp.sim.integrator_xpbd)
|
|
667
|
-
wp.load_module(warp.sim.integrator_xpbd, device=self.device)
|
|
668
|
-
elif self.solver == "semi_implicit":
|
|
669
|
-
wp.set_module_options({"block_dim": 256}, warp.sim.integrator_euler)
|
|
670
|
-
wp.load_module(warp.sim.integrator_euler, device=self.device)
|
|
671
|
-
wp.load_module(warp.sim.particles, device=self.device)
|
|
672
|
-
wp.load_module(warp.sim.integrator, device=self.device)
|
|
673
|
-
collide_module = importlib.import_module("warp.sim.collide")
|
|
674
|
-
wp.set_module_options({"block_dim": 256}, collide_module)
|
|
675
|
-
wp.load_module(collide_module, device=self.device)
|
|
676
|
-
wp.load_module(device=self.device)
|
|
677
|
-
with wp.ScopedCapture(device=self.device, force_module_load=False) as capture:
|
|
678
|
-
self.simulate()
|
|
679
|
-
self.graph = capture.graph
|
|
680
|
-
|
|
681
|
-
def simulate(self):
|
|
682
|
-
for _step in range(self.num_substeps):
|
|
683
|
-
self.state0.clear_forces()
|
|
684
|
-
wp.sim.collide(self.model, self.state0)
|
|
685
|
-
|
|
686
|
-
self.integrator.simulate(self.model, self.state0, self.state1, self.dt, None)
|
|
687
|
-
(self.state0, self.state1) = (self.state1, self.state0)
|
|
688
|
-
|
|
689
|
-
def run(self):
|
|
690
|
-
self.sim_time = 0.0
|
|
691
|
-
|
|
692
|
-
if self.do_rendering:
|
|
693
|
-
self.renderer = wp.sim.render.SimRendererOpenGL(self.model, "cloth_sim", scaling=self.renderer_scale_factor)
|
|
694
|
-
else:
|
|
695
|
-
self.renderer = None
|
|
696
|
-
|
|
697
|
-
for _frame in range(self.num_test_frames):
|
|
698
|
-
if self.graph:
|
|
699
|
-
wp.capture_launch(self.graph)
|
|
700
|
-
else:
|
|
701
|
-
self.simulate()
|
|
702
|
-
|
|
703
|
-
if self.renderer is not None:
|
|
704
|
-
self.renderer.begin_frame()
|
|
705
|
-
self.renderer.render(self.state0)
|
|
706
|
-
self.renderer.end_frame()
|
|
707
|
-
|
|
708
|
-
self.sim_time = self.sim_time + self.frame_dt
|
|
709
|
-
|
|
710
|
-
def set_points_fixed(self, model, fixed_particles):
|
|
711
|
-
if len(fixed_particles):
|
|
712
|
-
flags = model.particle_flags.numpy()
|
|
713
|
-
for fixed_v_id in fixed_particles:
|
|
714
|
-
flags[fixed_v_id] = wp.uint32(int(flags[fixed_v_id]) & ~int(PARTICLE_FLAG_ACTIVE))
|
|
715
|
-
|
|
716
|
-
model.particle_flags = wp.array(flags, device=model.device)
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
def test_cloth_sagging(test, device, solver):
|
|
720
|
-
example = ClothSim(device, solver, use_cuda_graph=True)
|
|
721
|
-
example.set_up_sagging_experiment()
|
|
722
|
-
|
|
723
|
-
initial_pos = example.state0.particle_q.numpy().copy()
|
|
724
|
-
|
|
725
|
-
example.run()
|
|
726
|
-
|
|
727
|
-
fixed_points = np.where(np.logical_not(example.model.particle_flags.numpy()))
|
|
728
|
-
# examine that the simulation does not explode
|
|
729
|
-
final_pos = example.state0.particle_q.numpy()
|
|
730
|
-
test.assertTrue((initial_pos[fixed_points, :] == final_pos[fixed_points, :]).all())
|
|
731
|
-
test.assertTrue((final_pos < 1e5).all())
|
|
732
|
-
# examine that the simulation has moved
|
|
733
|
-
test.assertTrue((example.init_pos != final_pos).any())
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
def test_cloth_bending(test, device, solver):
|
|
737
|
-
example = ClothSim(device, solver, use_cuda_graph=True)
|
|
738
|
-
example.set_up_bending_experiment()
|
|
739
|
-
|
|
740
|
-
example.run()
|
|
741
|
-
|
|
742
|
-
# examine that the simulation does not explode
|
|
743
|
-
final_pos = example.state0.particle_q.numpy()
|
|
744
|
-
test.assertTrue((final_pos < 1e5).all())
|
|
745
|
-
# examine that the simulation has moved
|
|
746
|
-
test.assertTrue((example.init_pos != final_pos).any())
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
def test_cloth_bending_non_zero_rest_angle_bending(test, device, solver):
|
|
750
|
-
example = ClothSim(device, solver, use_cuda_graph=True)
|
|
751
|
-
example.set_up_non_zero_rest_angle_bending_experiment()
|
|
752
|
-
|
|
753
|
-
example.run()
|
|
754
|
-
|
|
755
|
-
# examine that the simulation does not explode
|
|
756
|
-
final_pos = example.state0.particle_q.numpy()
|
|
757
|
-
test.assertTrue((np.abs(final_pos) < 1e5).all())
|
|
758
|
-
# examine that the simulation has moved
|
|
759
|
-
test.assertTrue((example.init_pos != final_pos).any())
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
def test_cloth_body_collision(test, device, solver):
|
|
763
|
-
example = ClothSim(device, solver, use_cuda_graph=True)
|
|
764
|
-
example.set_body_collision_experiment(handle_self_contact=False)
|
|
765
|
-
|
|
766
|
-
example.run()
|
|
767
|
-
|
|
768
|
-
# examine that the velocity has died out
|
|
769
|
-
final_vel = example.state0.particle_qd.numpy()
|
|
770
|
-
final_pos = example.state0.particle_q.numpy()
|
|
771
|
-
test.assertTrue((np.linalg.norm(final_vel, axis=1) < 1.0).all())
|
|
772
|
-
# examine that the simulation has moved
|
|
773
|
-
test.assertTrue((example.init_pos[:, 1] != final_pos[:, 1]).any())
|
|
774
|
-
|
|
775
|
-
# run again with handle_self_contact=True
|
|
776
|
-
example = ClothSim(device, solver, use_cuda_graph=True)
|
|
777
|
-
example.set_body_collision_experiment(handle_self_contact=True)
|
|
778
|
-
example.run()
|
|
779
|
-
# examine that the velocity has died out
|
|
780
|
-
final_vel = example.state0.particle_qd.numpy()
|
|
781
|
-
final_pos = example.state0.particle_q.numpy()
|
|
782
|
-
test.assertTrue((np.linalg.norm(final_vel, axis=1) < 1.0).all())
|
|
783
|
-
# examine that the simulation has moved
|
|
784
|
-
test.assertTrue((example.init_pos[:, 1] != final_pos[:, 1]).any())
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
def test_cloth_self_collision(test, device, solver):
|
|
788
|
-
example = ClothSim(device, solver, use_cuda_graph=True)
|
|
789
|
-
example.set_self_collision_experiment()
|
|
790
|
-
|
|
791
|
-
example.run()
|
|
792
|
-
|
|
793
|
-
# examine that the velocity has died out
|
|
794
|
-
final_vel = example.state0.particle_qd.numpy()
|
|
795
|
-
final_pos = example.state0.particle_q.numpy()
|
|
796
|
-
test.assertTrue((np.linalg.norm(final_vel, axis=1) < 1.0).all())
|
|
797
|
-
# examine that the simulation has moved
|
|
798
|
-
test.assertTrue((example.init_pos != final_pos).any())
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
def test_cloth_free_fall(test, device, solver):
|
|
802
|
-
example = ClothSim(device, solver)
|
|
803
|
-
example.set_free_falling_experiment()
|
|
804
|
-
|
|
805
|
-
initial_pos = example.state0.particle_q.numpy().copy()
|
|
806
|
-
|
|
807
|
-
example.run()
|
|
808
|
-
|
|
809
|
-
# examine that the simulation does not explode
|
|
810
|
-
final_pos = example.state0.particle_q.numpy()
|
|
811
|
-
test.assertTrue((final_pos < 1e5).all())
|
|
812
|
-
# examine that the simulation has moved
|
|
813
|
-
test.assertTrue((example.init_pos != final_pos).any())
|
|
814
|
-
|
|
815
|
-
gravity = np.array(example.model.gravity)
|
|
816
|
-
diff = final_pos - initial_pos
|
|
817
|
-
vertical_translation_norm = diff @ gravity[..., None] / (np.linalg.norm(gravity) ** 2)
|
|
818
|
-
# ensure it's free-falling
|
|
819
|
-
test.assertTrue((np.abs(vertical_translation_norm - 0.5 * np.linalg.norm(gravity) * (example.dt**2)) < 2e-1).all())
|
|
820
|
-
horizontal_move = diff - (vertical_translation_norm * gravity)
|
|
821
|
-
# ensure its horizontal translation is minimal
|
|
822
|
-
test.assertTrue((np.abs(horizontal_move) < 1e-1).all())
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
devices = get_test_devices(mode="basic")
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
class TestCloth(unittest.TestCase):
|
|
829
|
-
pass
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
tests_to_run = {
|
|
833
|
-
"xpbd": [
|
|
834
|
-
test_cloth_free_fall,
|
|
835
|
-
test_cloth_sagging,
|
|
836
|
-
test_cloth_bending,
|
|
837
|
-
test_cloth_bending_non_zero_rest_angle_bending,
|
|
838
|
-
],
|
|
839
|
-
"semi_implicit": [
|
|
840
|
-
test_cloth_free_fall,
|
|
841
|
-
test_cloth_sagging,
|
|
842
|
-
test_cloth_bending,
|
|
843
|
-
],
|
|
844
|
-
"vbd": [
|
|
845
|
-
test_cloth_free_fall,
|
|
846
|
-
test_cloth_sagging,
|
|
847
|
-
test_cloth_bending,
|
|
848
|
-
test_cloth_self_collision,
|
|
849
|
-
test_cloth_body_collision,
|
|
850
|
-
test_cloth_bending_non_zero_rest_angle_bending,
|
|
851
|
-
],
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
for solver, tests in tests_to_run.items():
|
|
855
|
-
for test in tests:
|
|
856
|
-
add_function_test(
|
|
857
|
-
TestCloth, f"{test.__name__}_{solver}", partial(test, solver=solver), devices=devices, check_output=False
|
|
858
|
-
)
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
if __name__ == "__main__":
|
|
862
|
-
wp.clear_kernel_cache()
|
|
863
|
-
unittest.main(verbosity=2, failfast=True)
|