-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathsph_rigid.py
More file actions
73 lines (61 loc) · 1.94 KB
/
Copy pathsph_rigid.py
File metadata and controls
73 lines (61 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import argparse
import os
import genesis as gs
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--vis", action="store_true", default=False)
args = parser.parse_args()
########################## init ##########################
gs.init(precision="32", logging_level="info")
########################## create a scene ##########################
scene = gs.Scene(
sim_options=gs.options.SimOptions(
dt=1e-2,
substeps=10,
),
sph_options=gs.options.SPHOptions(
lower_bound=(0.0, -1.0, 0.0),
upper_bound=(1.0, 1.0, 2.4),
),
vis_options=gs.options.VisOptions(
visualize_sph_boundary=True,
rendered_envs_idx=[0],
),
viewer_options=gs.options.ViewerOptions(
camera_pos=(3.5, -3.15, 2.42),
camera_lookat=(0.5, 0.0, 0.5),
camera_fov=40,
),
show_viewer=args.vis,
)
########################## entities ##########################
frictionless_rigid = gs.materials.Rigid(needs_coup=True, coup_friction=0.0)
plane = scene.add_entity(
morph=gs.morphs.Plane(),
)
water = scene.add_entity(
material=gs.materials.SPH.Liquid(mu=0.01, sampler="regular"),
morph=gs.morphs.Box(
pos=(0.5, 0.0, 0.6),
size=(0.9, 1.6, 1.2),
),
surface=gs.surfaces.Default(
color=(0.5, 0.7, 0.9, 1.0),
),
)
cube = scene.add_entity(
material=frictionless_rigid,
morph=gs.morphs.Box(
pos=(0.5, 0.0, 2.4),
size=(0.2, 0.2, 0.2),
euler=(30, 40, 0),
fixed=False,
),
)
########################## build ##########################
scene.build()
horizon = 500 if "PYTEST_VERSION" not in os.environ else 5
for i in range(horizon):
scene.step()
if __name__ == "__main__":
main()