-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgen_empty.py
113 lines (102 loc) · 2.08 KB
/
gen_empty.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
from mjcf import elements as e
def main():
#########################
# Level 1
mujoco = e.Mujoco(
model="empty"
)
#########################
# Level 2
option = e.Option(
integrator="RK4",
timestep=0.01
)
asset = e.Asset()
worldbody = e.Worldbody()
mujoco.add_children([
option,
asset,
worldbody
])
######################
# Level 3
# Asset
tex1 = e.Texture(
builtin="gradient",
height=100,
rgb1=[1, 1, 1],
rgb2=[0, 0, 0],
type="skybox",
width=100
)
tex2 = e.Texture(
builtin="flat",
height=1278,
mark="cross",
markrgb=[1, 1, 1],
name="texgeom",
random=0.01,
rgb1=[0.8, 0.6, 0.4],
rgb2=[0.8, 0.6, 0.4],
type="cube",
width=127
)
tex3 = e.Texture(
builtin="checker",
height=[100],
name="texplane",
rgb1=[0, 0, 0],
rgb2=[0.8, 0.8, 0.8],
type="2d",
width=100
)
mat1 = e.Material(
name="MatPlane",
reflectance=0.5,
shininess=1,
specular=1,
texrepeat=[60, 60],
texture="texplane"
)
mat2 = e.Material(
name="geom",
texture="texgeom",
texuniform=True
)
asset.add_children([
tex1,
tex2,
tex3,
mat1,
mat2,
])
# Worldbody
light = e.Light(
cutoff=100,
diffuse=[1, 1, 1],
dir=[-0, 0, -1.3],
directional=True,
exponent=1,
pos=[0, 0, 1.3],
specular=[.1, .1, .1]
)
floor_geom = e.Geom(
conaffinity=1,
condim=3,
material="MatPlane",
name="floor",
pos=[0, 0, 0],
rgba=[0.8, 0.9, 0.8, 1],
size=[40, 40, 40],
type="plane"
)
worldbody.add_children([
light,
floor_geom,
])
model_xml = mujoco.xml()
# Output
with open('empty-gen.xml', 'w') as fh:
fh.write(model_xml)
if __name__ == '__main__':
main()