-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathamass_char_info.py
391 lines (363 loc) · 9.2 KB
/
amass_char_info.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# Copyright (c) Facebook, Inc. and its affiliates.
# copied from ScaDiver repo, a lot of these not used
import collections
import numpy as np
'''
The up direction of the character w.r.t. its root joint.
The up direction in the world frame can be computed by dot(R_root, v_up),
where R_root is the orientation of the root.
'''
v_up = np.array([0.0, 1.0, 0.0])
'''
The facing direction of the character w.r.t. its root joint.
The facing direction in the world frame can be computed by dot(R_root, v_face),
where R_root is the orientation of the root.
'''
v_face = np.array([0.0, 0.0, 1.0])
'''
The up direction of the world frame, when the character holds its defalult posture (e.g. t-pose).
This information is useful/necessary when comparing a relationship between the character and its environment.
'''
v_up_env = np.array([0.0, 0.0, 1.0])
'''
Definition of Link/Joint (In our character definition, one joint can only have one link)
'''
root = -1
lhip = 0
lknee = 1
lankle = 2
rhip = 3
rknee = 4
rankle = 5
lowerback = 6
upperback = 7
chest = 8
lowerneck = 9
upperneck = 10
lclavicle = 11
lshoulder = 12
lelbow = 13
lwrist = 14
rclavicle = 15
rshoulder = 16
relbow = 17
rwrist = 18
'''
Definition of the root (base) joint
'''
ROOT = root
'''
Definition of end effectors
'''
end_effector_indices = [
lwrist, rwrist, lankle, rankle,
]
'''
Mapping from Bullet indices to Nimble indices
'''
nimble_map = collections.OrderedDict()
nimble_map[root] = 0
nimble_map[lhip] = 1
nimble_map[lknee] = 2
nimble_map[lankle] = 3
nimble_map[rhip] = 17
nimble_map[rknee] = 18
nimble_map[rankle] = 19
nimble_map[lowerback] = 4
nimble_map[upperback] = 5
nimble_map[chest] = 6
nimble_map[lowerneck] = 11
nimble_map[upperneck] = 12
nimble_map[lclavicle] = 7
nimble_map[lshoulder] = 8
nimble_map[lelbow] = 9
nimble_map[lwrist] = 10
nimble_map[rclavicle] = 13
nimble_map[rshoulder] = 14
nimble_map[relbow] = 15
nimble_map[rwrist] = 16
'''
Mapping from Bullet indices to Nimble state indices (no weld joints)
'''
nimble_state_map = collections.OrderedDict()
nimble_state_map[root] = 0
nimble_state_map[lhip] = 1
nimble_state_map[lknee] = 2
nimble_state_map[lankle] = 3
nimble_state_map[rhip] = 15
nimble_state_map[rknee] = 16
nimble_state_map[rankle] = 17
nimble_state_map[lowerback] = 4
nimble_state_map[upperback] = 5
nimble_state_map[chest] = 6
nimble_state_map[lowerneck] = 10
nimble_state_map[upperneck] = 11
nimble_state_map[lclavicle] = 7
nimble_state_map[lshoulder] = 8
nimble_state_map[lelbow] = 9
nimble_state_map[lwrist] = None
nimble_state_map[rclavicle] = 12
nimble_state_map[rshoulder] = 13
nimble_state_map[relbow] = 14
nimble_state_map[rwrist] = None
'''
Mapping from joint indicies to names
'''
joint_name = collections.OrderedDict()
joint_name[root] = "root"
joint_name[lhip] = "lhip"
joint_name[lknee] = "lknee"
joint_name[lankle] = "lankle"
joint_name[rhip] = "rhip"
joint_name[rknee] = "rknee"
joint_name[rankle] = "rankle"
joint_name[lowerback] = "lowerback"
joint_name[upperback] = "upperback"
joint_name[chest] = "chest"
joint_name[lowerneck] = "lowerneck"
joint_name[upperneck] = "upperneck"
joint_name[lclavicle] = "lclavicle"
joint_name[lshoulder] = "lshoulder"
joint_name[lelbow] = "lelbow"
joint_name[lwrist] = "lwrist"
joint_name[rclavicle] = "rclavicle"
joint_name[rshoulder] = "rshoulder"
joint_name[relbow] = "relbow"
joint_name[rwrist] = "rwrist"
'''
Mapping from joint names to indicies
'''
joint_idx = collections.OrderedDict()
joint_idx["root"] = root
joint_idx["lhip"] = lhip
joint_idx["lknee"] = lknee
joint_idx["lankle"] = lankle
joint_idx["rhip"] = rhip
joint_idx["rknee"] = rknee
joint_idx["rankle"] = rankle
joint_idx["lowerback"] = lowerback
joint_idx["upperback"] = upperback
joint_idx["chest"] = chest
joint_idx["lowerneck"] = lowerneck
joint_idx["upperneck"] = upperneck
joint_idx["lclavicle"] = lclavicle
joint_idx["lshoulder"] = lshoulder
joint_idx["lelbow"] = lelbow
joint_idx["lwrist"] = lwrist
joint_idx["rclavicle"] = rclavicle
joint_idx["rshoulder"] = rshoulder
joint_idx["relbow"] = relbow
joint_idx["rwrist"] = rwrist
'''
Mapping from character's joint indicies to bvh's joint names.
Some entry could have no mapping (by assigning None).
'''
bvh_map = collections.OrderedDict()
bvh_map[root] = "root"
bvh_map[lhip] = "lhip"
bvh_map[lknee] = "lknee"
bvh_map[lankle] = "lankle"
bvh_map[rhip] = "rhip"
bvh_map[rknee] = "rknee"
bvh_map[rankle] = "rankle"
bvh_map[lowerback] = "lowerback"
bvh_map[upperback] = "upperback"
bvh_map[chest] = "chest"
bvh_map[lowerneck] = "lowerneck"
bvh_map[upperneck] = "upperneck"
bvh_map[lclavicle] = "lclavicle"
bvh_map[lshoulder] = "lshoulder"
bvh_map[lelbow] = "lelbow"
bvh_map[lwrist] = "lwrist"
bvh_map[rclavicle] = "rclavicle"
bvh_map[rshoulder] = "rshoulder"
bvh_map[relbow] = "relbow"
bvh_map[rwrist] = "rwrist"
'''
Mapping from bvh's joint names to character's joint indicies.
Some entry could have no mapping (by assigning None).
'''
bvh_map_inv = collections.OrderedDict()
bvh_map_inv["root"] = root
bvh_map_inv["lhip"] = lhip
bvh_map_inv["lknee"] = lknee
bvh_map_inv["lankle"] = lankle
bvh_map_inv["ltoe"] = None
bvh_map_inv["rhip"] = rhip
bvh_map_inv["rknee"] = rknee
bvh_map_inv["rankle"] = rankle
bvh_map_inv["rtoe"] = None
bvh_map_inv["lowerback"] = lowerback
bvh_map_inv["upperback"] = upperback
bvh_map_inv["chest"] = chest
bvh_map_inv["lowerneck"] = lowerneck
bvh_map_inv["upperneck"] = upperneck
bvh_map_inv["lclavicle"] = lclavicle
bvh_map_inv["lshoulder"] = lshoulder
bvh_map_inv["lelbow"] = lelbow
bvh_map_inv["lwrist"] = lwrist
bvh_map_inv["rclavicle"] = rclavicle
bvh_map_inv["rshoulder"] = rshoulder
bvh_map_inv["relbow"] = relbow
bvh_map_inv["rwrist"] = rwrist
bvh_map_inv["lhand"] = None
bvh_map_inv["rhand"] = None
'''
Definition of PD gains (tuned for Stable PD Controller)
'''
kp = {
root: 0,
lhip: 500,
lknee: 400,
lankle: 300,
rhip: 500,
rknee: 400,
rankle: 300,
lowerback: 500,
upperback: 500,
chest: 500,
lowerneck: 200,
upperneck: 200,
lclavicle: 400,
lshoulder: 400,
lelbow: 300,
lwrist: 0,
rclavicle: 400,
rshoulder: 400,
relbow: 300,
rwrist: 0,
}
kd = {}
for k, v in kp.items():
kd[k] = 0.1 * v
kd[root] = 0
'''
Definition of PD gains (tuned for Contrained PD Controller).
"cpd_ratio * kp" and "cpd_ratio * kd" will be used respectively.
'''
cpd_ratio = 0.0002
max_force = {
root: 0,
lhip: 300,
lknee: 200,
lankle: 100,
rhip: 300,
rknee: 200,
rankle: 100,
lowerback: 300,
upperback: 300,
chest: 300,
lowerneck: 100,
upperneck: 100,
lclavicle: 200,
lshoulder: 200,
lelbow: 150,
lwrist: 0,
rclavicle: 200,
rshoulder: 200,
relbow: 150,
rwrist: 0,
}
'''
Maximum forces that character can generate when PD controller is used.
'''
contact_allow_map = {
root: False,
lhip: False,
lknee: False,
lankle: False,
rhip: False,
rknee: False,
rankle: False,
lowerback: False,
upperback: False,
chest: False,
lowerneck: False,
upperneck: False,
lclavicle: False,
lshoulder: False,
lelbow: False,
lwrist: False,
rclavicle: False,
rshoulder: False,
relbow: False,
rwrist: False,
}
joint_weight = {
root: 1.0,
lhip: 0.5,
lknee: 0.3,
lankle: 0.2,
rhip: 0.5,
rknee: 0.3,
rankle: 0.2,
lowerback: 0.4,
upperback: 0.4,
chest: 0.3,
lowerneck: 0.3,
upperneck: 0.3,
lclavicle: 0.3,
lshoulder: 0.3,
lelbow: 0.2,
lwrist: 0.0,
rclavicle: 0.3,
rshoulder: 0.3,
relbow: 0.2,
rwrist: 0.0,
}
''' mu, sigma, lower, upper '''
noise_pose = {
root: (0.0, 0.1, -0.5, 0.5),
lhip: (0.0, 0.1, -0.5, 0.5),
lknee: (0.0, 0.1, -0.5, 0.5),
lankle: (0.0, 0.1, -0.5, 0.5),
rhip: (0.0, 0.1, -0.5, 0.5),
rknee: (0.0, 0.1, -0.5, 0.5),
rankle: (0.0, 0.1, -0.5, 0.5),
lowerback: (0.0, 0.1, -0.5, 0.5),
upperback: (0.0, 0.1, -0.5, 0.5),
chest: (0.0, 0.1, -0.5, 0.5),
lowerneck: (0.0, 0.1, -0.5, 0.5),
upperneck: (0.0, 0.1, -0.5, 0.5),
lclavicle: (0.0, 0.1, -0.5, 0.5),
lshoulder: (0.0, 0.1, -0.5, 0.5),
lelbow: (0.0, 0.1, -0.5, 0.5),
lwrist: (0.0, 0.1, -0.5, 0.5),
rclavicle: (0.0, 0.1, -0.5, 0.5),
rshoulder: (0.0, 0.1, -0.5, 0.5),
relbow: (0.0, 0.1, -0.5, 0.5),
rwrist: (0.0, 0.1, -0.5, 0.5),
}
''' mu, sigma, lower, upper '''
noise_vel = {
root: (0.0, 0.1, -0.5, 0.5),
lhip: (0.0, 0.1, -0.5, 0.5),
lknee: (0.0, 0.1, -0.5, 0.5),
lankle: (0.0, 0.1, -0.5, 0.5),
rhip: (0.0, 0.1, -0.5, 0.5),
rknee: (0.0, 0.1, -0.5, 0.5),
rankle: (0.0, 0.1, -0.5, 0.5),
lowerback: (0.0, 0.1, -0.5, 0.5),
upperback: (0.0, 0.1, -0.5, 0.5),
chest: (0.0, 0.1, -0.5, 0.5),
lowerneck: (0.0, 0.1, -0.5, 0.5),
upperneck: (0.0, 0.1, -0.5, 0.5),
lclavicle: (0.0, 0.1, -0.5, 0.5),
lshoulder: (0.0, 0.1, -0.5, 0.5),
lelbow: (0.0, 0.1, -0.5, 0.5),
lwrist: (0.0, 0.1, -0.5, 0.5),
rclavicle: (0.0, 0.1, -0.5, 0.5),
rshoulder: (0.0, 0.1, -0.5, 0.5),
relbow: (0.0, 0.1, -0.5, 0.5),
rwrist: (0.0, 0.1, -0.5, 0.5),
}
collison_ignore_pairs = [
]
friction_lateral = 0.8
friction_spinning = 0.3
restitution = 0.0
sum_joint_weight = 0.0
for key, val in joint_weight.items():
sum_joint_weight += val
for key, val in joint_weight.items():
joint_weight[key] /= sum_joint_weight