warp-lang 0.11.0__py3-none-manylinux2014_x86_64.whl → 1.0.0__py3-none-manylinux2014_x86_64.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 +8 -0
- warp/bin/warp-clang.so +0 -0
- warp/bin/warp.so +0 -0
- warp/build.py +7 -6
- warp/build_dll.py +70 -79
- warp/builtins.py +10 -6
- warp/codegen.py +51 -19
- warp/config.py +7 -8
- warp/constants.py +3 -0
- warp/context.py +948 -245
- warp/dlpack.py +198 -113
- warp/examples/assets/bunny.usd +0 -0
- warp/examples/assets/cartpole.urdf +110 -0
- warp/examples/assets/crazyflie.usd +0 -0
- warp/examples/assets/cube.usda +42 -0
- warp/examples/assets/nv_ant.xml +92 -0
- warp/examples/assets/nv_humanoid.xml +183 -0
- warp/examples/assets/quadruped.urdf +268 -0
- warp/examples/assets/rocks.nvdb +0 -0
- warp/examples/assets/rocks.usd +0 -0
- warp/examples/assets/sphere.usda +56 -0
- warp/examples/assets/torus.usda +105 -0
- warp/examples/benchmarks/benchmark_api.py +383 -0
- warp/examples/benchmarks/benchmark_cloth.py +279 -0
- warp/examples/benchmarks/benchmark_cloth_cupy.py +88 -0
- warp/examples/benchmarks/benchmark_cloth_jax.py +100 -0
- warp/examples/benchmarks/benchmark_cloth_numba.py +142 -0
- warp/examples/benchmarks/benchmark_cloth_numpy.py +77 -0
- warp/examples/benchmarks/benchmark_cloth_pytorch.py +86 -0
- warp/examples/benchmarks/benchmark_cloth_taichi.py +112 -0
- warp/examples/benchmarks/benchmark_cloth_warp.py +146 -0
- warp/examples/benchmarks/benchmark_launches.py +295 -0
- warp/examples/core/example_dem.py +221 -0
- warp/examples/core/example_fluid.py +267 -0
- warp/examples/core/example_graph_capture.py +129 -0
- warp/examples/core/example_marching_cubes.py +177 -0
- warp/examples/core/example_mesh.py +154 -0
- warp/examples/core/example_mesh_intersect.py +193 -0
- warp/examples/core/example_nvdb.py +169 -0
- warp/examples/core/example_raycast.py +89 -0
- warp/examples/core/example_raymarch.py +178 -0
- warp/examples/core/example_render_opengl.py +141 -0
- warp/examples/core/example_sph.py +389 -0
- warp/examples/core/example_torch.py +181 -0
- warp/examples/core/example_wave.py +249 -0
- warp/examples/fem/bsr_utils.py +380 -0
- warp/examples/fem/example_apic_fluid.py +391 -0
- warp/examples/fem/example_convection_diffusion.py +168 -0
- warp/examples/fem/example_convection_diffusion_dg.py +209 -0
- warp/examples/fem/example_convection_diffusion_dg0.py +194 -0
- warp/examples/fem/example_deformed_geometry.py +159 -0
- warp/examples/fem/example_diffusion.py +173 -0
- warp/examples/fem/example_diffusion_3d.py +152 -0
- warp/examples/fem/example_diffusion_mgpu.py +214 -0
- warp/examples/fem/example_mixed_elasticity.py +222 -0
- warp/examples/fem/example_navier_stokes.py +243 -0
- warp/examples/fem/example_stokes.py +192 -0
- warp/examples/fem/example_stokes_transfer.py +249 -0
- warp/examples/fem/mesh_utils.py +109 -0
- warp/examples/fem/plot_utils.py +287 -0
- warp/examples/optim/example_bounce.py +248 -0
- warp/examples/optim/example_cloth_throw.py +210 -0
- warp/examples/optim/example_diffray.py +535 -0
- warp/examples/optim/example_drone.py +850 -0
- warp/examples/optim/example_inverse_kinematics.py +169 -0
- warp/examples/optim/example_inverse_kinematics_torch.py +170 -0
- warp/examples/optim/example_spring_cage.py +234 -0
- warp/examples/optim/example_trajectory.py +201 -0
- warp/examples/sim/example_cartpole.py +128 -0
- warp/examples/sim/example_cloth.py +184 -0
- warp/examples/sim/example_granular.py +113 -0
- warp/examples/sim/example_granular_collision_sdf.py +185 -0
- warp/examples/sim/example_jacobian_ik.py +213 -0
- warp/examples/sim/example_particle_chain.py +106 -0
- warp/examples/sim/example_quadruped.py +179 -0
- warp/examples/sim/example_rigid_chain.py +191 -0
- warp/examples/sim/example_rigid_contact.py +176 -0
- warp/examples/sim/example_rigid_force.py +126 -0
- warp/examples/sim/example_rigid_gyroscopic.py +97 -0
- warp/examples/sim/example_rigid_soft_contact.py +124 -0
- warp/examples/sim/example_soft_body.py +178 -0
- warp/fabric.py +29 -20
- warp/fem/cache.py +0 -1
- warp/fem/dirichlet.py +0 -2
- warp/fem/integrate.py +0 -1
- warp/jax.py +45 -0
- warp/jax_experimental.py +339 -0
- warp/native/builtin.h +12 -0
- warp/native/bvh.cu +18 -18
- warp/native/clang/clang.cpp +8 -3
- warp/native/cuda_util.cpp +94 -5
- warp/native/cuda_util.h +35 -6
- warp/native/cutlass_gemm.cpp +1 -1
- warp/native/cutlass_gemm.cu +4 -1
- warp/native/error.cpp +66 -0
- warp/native/error.h +27 -0
- warp/native/mesh.cu +2 -2
- warp/native/reduce.cu +4 -4
- warp/native/runlength_encode.cu +2 -2
- warp/native/scan.cu +2 -2
- warp/native/sparse.cu +0 -1
- warp/native/temp_buffer.h +2 -2
- warp/native/warp.cpp +95 -60
- warp/native/warp.cu +1053 -218
- warp/native/warp.h +49 -32
- warp/optim/linear.py +33 -16
- warp/render/render_opengl.py +202 -101
- warp/render/render_usd.py +82 -40
- warp/sim/__init__.py +13 -4
- warp/sim/articulation.py +4 -5
- warp/sim/collide.py +320 -175
- warp/sim/import_mjcf.py +25 -30
- warp/sim/import_urdf.py +94 -63
- warp/sim/import_usd.py +51 -36
- warp/sim/inertia.py +3 -2
- warp/sim/integrator.py +233 -0
- warp/sim/integrator_euler.py +447 -469
- warp/sim/integrator_featherstone.py +1991 -0
- warp/sim/integrator_xpbd.py +1420 -640
- warp/sim/model.py +765 -487
- warp/sim/particles.py +2 -1
- warp/sim/render.py +35 -13
- warp/sim/utils.py +222 -11
- warp/stubs.py +8 -0
- warp/tape.py +16 -1
- warp/tests/aux_test_grad_customs.py +23 -0
- warp/tests/test_array.py +190 -1
- warp/tests/test_async.py +656 -0
- warp/tests/test_bool.py +50 -0
- warp/tests/test_dlpack.py +164 -11
- warp/tests/test_examples.py +166 -74
- warp/tests/test_fem.py +8 -1
- warp/tests/test_generics.py +15 -5
- warp/tests/test_grad.py +1 -1
- warp/tests/test_grad_customs.py +172 -12
- warp/tests/test_jax.py +254 -0
- warp/tests/test_large.py +29 -6
- warp/tests/test_launch.py +25 -0
- warp/tests/test_linear_solvers.py +20 -3
- warp/tests/test_matmul.py +61 -16
- warp/tests/test_matmul_lite.py +13 -13
- warp/tests/test_mempool.py +186 -0
- warp/tests/test_multigpu.py +3 -0
- warp/tests/test_options.py +16 -2
- warp/tests/test_peer.py +137 -0
- warp/tests/test_print.py +3 -1
- warp/tests/test_quat.py +23 -0
- warp/tests/test_sim_kinematics.py +97 -0
- warp/tests/test_snippet.py +126 -3
- warp/tests/test_streams.py +108 -79
- warp/tests/test_torch.py +16 -8
- warp/tests/test_utils.py +32 -27
- warp/tests/test_verify_fp.py +65 -0
- warp/tests/test_volume.py +1 -1
- warp/tests/unittest_serial.py +2 -0
- warp/tests/unittest_suites.py +12 -0
- warp/tests/unittest_utils.py +14 -7
- warp/thirdparty/unittest_parallel.py +15 -3
- warp/torch.py +10 -8
- warp/types.py +363 -246
- warp/utils.py +143 -19
- warp_lang-1.0.0.dist-info/LICENSE.md +126 -0
- warp_lang-1.0.0.dist-info/METADATA +394 -0
- {warp_lang-0.11.0.dist-info → warp_lang-1.0.0.dist-info}/RECORD +167 -86
- warp/sim/optimizer.py +0 -138
- warp_lang-0.11.0.dist-info/LICENSE.md +0 -36
- warp_lang-0.11.0.dist-info/METADATA +0 -238
- /warp/tests/{walkthough_debug.py → walkthrough_debug.py} +0 -0
- {warp_lang-0.11.0.dist-info → warp_lang-1.0.0.dist-info}/WHEEL +0 -0
- {warp_lang-0.11.0.dist-info → warp_lang-1.0.0.dist-info}/top_level.txt +0 -0
warp/sim/integrator.py
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# Copyright (c) 2022 NVIDIA CORPORATION. All rights reserved.
|
|
2
|
+
# NVIDIA CORPORATION and its licensors retain all intellectual property
|
|
3
|
+
# and proprietary rights in and to this software, related documentation
|
|
4
|
+
# and any modifications thereto. Any use, reproduction, disclosure or
|
|
5
|
+
# distribution of this software and related documentation without an express
|
|
6
|
+
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
|
7
|
+
|
|
8
|
+
import warp as wp
|
|
9
|
+
from .model import Model, State, Control, PARTICLE_FLAG_ACTIVE
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@wp.kernel
|
|
13
|
+
def integrate_particles(
|
|
14
|
+
x: wp.array(dtype=wp.vec3),
|
|
15
|
+
v: wp.array(dtype=wp.vec3),
|
|
16
|
+
f: wp.array(dtype=wp.vec3),
|
|
17
|
+
w: wp.array(dtype=float),
|
|
18
|
+
particle_flags: wp.array(dtype=wp.uint32),
|
|
19
|
+
gravity: wp.vec3,
|
|
20
|
+
dt: float,
|
|
21
|
+
v_max: float,
|
|
22
|
+
x_new: wp.array(dtype=wp.vec3),
|
|
23
|
+
v_new: wp.array(dtype=wp.vec3),
|
|
24
|
+
):
|
|
25
|
+
tid = wp.tid()
|
|
26
|
+
if (particle_flags[tid] & PARTICLE_FLAG_ACTIVE) == 0:
|
|
27
|
+
return
|
|
28
|
+
|
|
29
|
+
x0 = x[tid]
|
|
30
|
+
v0 = v[tid]
|
|
31
|
+
f0 = f[tid]
|
|
32
|
+
|
|
33
|
+
inv_mass = w[tid]
|
|
34
|
+
|
|
35
|
+
# simple semi-implicit Euler. v1 = v0 + a dt, x1 = x0 + v1 dt
|
|
36
|
+
v1 = v0 + (f0 * inv_mass + gravity * wp.step(-inv_mass)) * dt
|
|
37
|
+
# enforce velocity limit to prevent instability
|
|
38
|
+
v1_mag = wp.length(v1)
|
|
39
|
+
if v1_mag > v_max:
|
|
40
|
+
v1 *= v_max / v1_mag
|
|
41
|
+
x1 = x0 + v1 * dt
|
|
42
|
+
|
|
43
|
+
x_new[tid] = x1
|
|
44
|
+
v_new[tid] = v1
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@wp.func
|
|
48
|
+
def integrate_rigid_body(
|
|
49
|
+
q: wp.transform,
|
|
50
|
+
qd: wp.spatial_vector,
|
|
51
|
+
f: wp.spatial_vector,
|
|
52
|
+
com: wp.vec3,
|
|
53
|
+
inertia: wp.mat33,
|
|
54
|
+
inv_mass: float,
|
|
55
|
+
inv_inertia: wp.mat33,
|
|
56
|
+
gravity: wp.vec3,
|
|
57
|
+
angular_damping: float,
|
|
58
|
+
dt: float,
|
|
59
|
+
):
|
|
60
|
+
# unpack transform
|
|
61
|
+
x0 = wp.transform_get_translation(q)
|
|
62
|
+
r0 = wp.transform_get_rotation(q)
|
|
63
|
+
|
|
64
|
+
# unpack spatial twist
|
|
65
|
+
w0 = wp.spatial_top(qd)
|
|
66
|
+
v0 = wp.spatial_bottom(qd)
|
|
67
|
+
|
|
68
|
+
# unpack spatial wrench
|
|
69
|
+
t0 = wp.spatial_top(f)
|
|
70
|
+
f0 = wp.spatial_bottom(f)
|
|
71
|
+
|
|
72
|
+
x_com = x0 + wp.quat_rotate(r0, com)
|
|
73
|
+
|
|
74
|
+
# linear part
|
|
75
|
+
v1 = v0 + (f0 * inv_mass + gravity * wp.nonzero(inv_mass)) * dt
|
|
76
|
+
x1 = x_com + v1 * dt
|
|
77
|
+
|
|
78
|
+
# angular part (compute in body frame)
|
|
79
|
+
wb = wp.quat_rotate_inv(r0, w0)
|
|
80
|
+
tb = wp.quat_rotate_inv(r0, t0) - wp.cross(wb, inertia * wb) # coriolis forces
|
|
81
|
+
|
|
82
|
+
w1 = wp.quat_rotate(r0, wb + inv_inertia * tb * dt)
|
|
83
|
+
r1 = wp.normalize(r0 + wp.quat(w1, 0.0) * r0 * 0.5 * dt)
|
|
84
|
+
|
|
85
|
+
# angular damping
|
|
86
|
+
w1 *= 1.0 - angular_damping * dt
|
|
87
|
+
|
|
88
|
+
q_new = wp.transform(x1 - wp.quat_rotate(r1, com), r1)
|
|
89
|
+
qd_new = wp.spatial_vector(w1, v1)
|
|
90
|
+
|
|
91
|
+
return q_new, qd_new
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# semi-implicit Euler integration
|
|
95
|
+
@wp.kernel
|
|
96
|
+
def integrate_bodies(
|
|
97
|
+
body_q: wp.array(dtype=wp.transform),
|
|
98
|
+
body_qd: wp.array(dtype=wp.spatial_vector),
|
|
99
|
+
body_f: wp.array(dtype=wp.spatial_vector),
|
|
100
|
+
body_com: wp.array(dtype=wp.vec3),
|
|
101
|
+
m: wp.array(dtype=float),
|
|
102
|
+
I: wp.array(dtype=wp.mat33),
|
|
103
|
+
inv_m: wp.array(dtype=float),
|
|
104
|
+
inv_I: wp.array(dtype=wp.mat33),
|
|
105
|
+
gravity: wp.vec3,
|
|
106
|
+
angular_damping: float,
|
|
107
|
+
dt: float,
|
|
108
|
+
# outputs
|
|
109
|
+
body_q_new: wp.array(dtype=wp.transform),
|
|
110
|
+
body_qd_new: wp.array(dtype=wp.spatial_vector),
|
|
111
|
+
):
|
|
112
|
+
tid = wp.tid()
|
|
113
|
+
|
|
114
|
+
# positions
|
|
115
|
+
q = body_q[tid]
|
|
116
|
+
qd = body_qd[tid]
|
|
117
|
+
f = body_f[tid]
|
|
118
|
+
|
|
119
|
+
# masses
|
|
120
|
+
inv_mass = inv_m[tid] # 1 / mass
|
|
121
|
+
|
|
122
|
+
inertia = I[tid]
|
|
123
|
+
inv_inertia = inv_I[tid] # inverse of 3x3 inertia matrix
|
|
124
|
+
|
|
125
|
+
com = body_com[tid]
|
|
126
|
+
|
|
127
|
+
q_new, qd_new = integrate_rigid_body(
|
|
128
|
+
q,
|
|
129
|
+
qd,
|
|
130
|
+
f,
|
|
131
|
+
com,
|
|
132
|
+
inertia,
|
|
133
|
+
inv_mass,
|
|
134
|
+
inv_inertia,
|
|
135
|
+
gravity,
|
|
136
|
+
angular_damping,
|
|
137
|
+
dt,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
body_q_new[tid] = q_new
|
|
141
|
+
body_qd_new[tid] = qd_new
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class Integrator:
|
|
145
|
+
"""
|
|
146
|
+
Generic base class for integrators. Provides methods to integrate rigid bodies and particles.
|
|
147
|
+
"""
|
|
148
|
+
|
|
149
|
+
def integrate_bodies(
|
|
150
|
+
self,
|
|
151
|
+
model: Model,
|
|
152
|
+
state_in: State,
|
|
153
|
+
state_out: State,
|
|
154
|
+
dt: float,
|
|
155
|
+
angular_damping: float = 0.0,
|
|
156
|
+
):
|
|
157
|
+
"""
|
|
158
|
+
Integrate the rigid bodies of the model.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
model (Model): The model to integrate.
|
|
162
|
+
state_in (State): The input state.
|
|
163
|
+
state_out (State): The output state.
|
|
164
|
+
dt (float): The time step (typically in seconds).
|
|
165
|
+
angular_damping (float, optional): The angular damping factor. Defaults to 0.0.
|
|
166
|
+
"""
|
|
167
|
+
if model.body_count:
|
|
168
|
+
wp.launch(
|
|
169
|
+
kernel=integrate_bodies,
|
|
170
|
+
dim=model.body_count,
|
|
171
|
+
inputs=[
|
|
172
|
+
state_in.body_q,
|
|
173
|
+
state_in.body_qd,
|
|
174
|
+
state_in.body_f,
|
|
175
|
+
model.body_com,
|
|
176
|
+
model.body_mass,
|
|
177
|
+
model.body_inertia,
|
|
178
|
+
model.body_inv_mass,
|
|
179
|
+
model.body_inv_inertia,
|
|
180
|
+
model.gravity,
|
|
181
|
+
angular_damping,
|
|
182
|
+
dt,
|
|
183
|
+
],
|
|
184
|
+
outputs=[state_out.body_q, state_out.body_qd],
|
|
185
|
+
device=model.device,
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
def integrate_particles(
|
|
189
|
+
self,
|
|
190
|
+
model: Model,
|
|
191
|
+
state_in: State,
|
|
192
|
+
state_out: State,
|
|
193
|
+
dt: float,
|
|
194
|
+
):
|
|
195
|
+
"""
|
|
196
|
+
Integrate the particles of the model.
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
model (Model): The model to integrate.
|
|
200
|
+
state_in (State): The input state.
|
|
201
|
+
state_out (State): The output state.
|
|
202
|
+
dt (float): The time step (typically in seconds).
|
|
203
|
+
"""
|
|
204
|
+
if model.particle_count:
|
|
205
|
+
wp.launch(
|
|
206
|
+
kernel=integrate_particles,
|
|
207
|
+
dim=model.particle_count,
|
|
208
|
+
inputs=[
|
|
209
|
+
state_in.particle_q,
|
|
210
|
+
state_in.particle_qd,
|
|
211
|
+
state_in.particle_f,
|
|
212
|
+
model.particle_inv_mass,
|
|
213
|
+
model.particle_flags,
|
|
214
|
+
model.gravity,
|
|
215
|
+
dt,
|
|
216
|
+
model.particle_max_velocity,
|
|
217
|
+
],
|
|
218
|
+
outputs=[state_out.particle_q, state_out.particle_qd],
|
|
219
|
+
device=model.device,
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
def simulate(self, model: Model, state_in: State, state_out: State, dt: float, control: Control = None):
|
|
223
|
+
"""
|
|
224
|
+
Simulate the model for a given time step using the given control input.
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
model (Model): The model to simulate.
|
|
228
|
+
state_in (State): The input state.
|
|
229
|
+
state_out (State): The output state.
|
|
230
|
+
dt (float): The time step (typically in seconds).
|
|
231
|
+
control (Control): The control input. Defaults to `None` which means the control values from the :class:`Model` are used.
|
|
232
|
+
"""
|
|
233
|
+
raise NotImplementedError()
|