forked from Genesis-Embodied-AI/Genesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelastic_dragon.py
58 lines (45 loc) · 1.49 KB
/
elastic_dragon.py
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
import argparse
import numpy as np
import genesis as gs
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--vis", action="store_true", default=False)
parser.add_argument("-c", "--cpu", action="store_true", default=False)
args = parser.parse_args()
########################## init ##########################
gs.init(backend=gs.cpu if args.cpu else gs.gpu, logging_level="debug")
########################## create a scene ##########################
scene = gs.Scene(
sim_options=gs.options.SimOptions(
substeps=10,
gravity=(0, 0, -9.8),
),
viewer_options=gs.options.ViewerOptions(
camera_pos=(2, 2, 1.5),
camera_lookat=(0, 0, 0.5),
camera_up=(0, 0, 1),
),
show_viewer=args.vis,
)
########################## materials ##########################
mat_elastic = gs.materials.PBD.Elastic()
########################## entities ##########################
bunny = scene.add_entity(
material=mat_elastic,
morph=gs.morphs.Mesh(
file="meshes/dragon/dragon.obj",
scale=0.003,
pos=(0, 0, 0.8),
),
surface=gs.surfaces.Default(
# vis_mode='recon',
),
)
########################## build ##########################
scene.build()
horizon = 1000
# forward pass
for i in range(horizon):
scene.step()
if __name__ == "__main__":
main()