Skip to content

Commit 99025d6

Browse files
committed
fixed all formatting issues; checked that the model still compiles with the new muscle model; removed muscles that did not converge because of odd geometries
1 parent 2d4846f commit 99025d6

14 files changed

Lines changed: 2911 additions & 2687 deletions

dm_control/locomotion/walkers/assets/dog_v2/add_markers.py

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,61 @@
1616
"""Add markers to the dog model, used for motion capture tracking."""
1717

1818
MARKERS_PER_BODY = {
19-
'torso': ((-0.25, 0, 0.13), (-0.1, 0, 0.13), (0.05, 0, 0.15),
20-
(-0.25, -0.06, -0.01), (-0.1, -0.08, -0.02), (0.05, -0.09, -0.02),
21-
(-0.25, 0.06, -0.01), (-0.1, 0.08, -0.02), (0.05, 0.09, -0.02)),
22-
'C_6': ((0.05, -0.05, 0), (0.05, 0.05, 0)),
23-
'upper_arm': ((0.04, 0, 0)),
24-
'lower_arm': ((0.025, 0, 0), (0.025, 0, -0.1)),
25-
'hand': ((0, -0.02, 0), (0, 0.02, 0), (0.02, -0.02, -0.08),
26-
(0.02, 0.02, -0.08)),
27-
'finger': ((0.065, 0, 0)),
28-
'pelvis': ((0.04, -0.07, 0.02), (0.04, 0.07, 0.02)),
29-
'upper_leg': ((-0.03, 0.04, 0)),
30-
'lower_leg': ((0.04, 0, 0), (-0.04, 0.035, 0)),
31-
'foot': ((0, -0.02, 0), (0, 0.02, 0), (0, -0.02, -0.1), (0, 0.03, -0.1)),
32-
'toe': ((0.055, 0, 0)),
33-
'Ca_10': ((0, 0, 0.01)),
34-
'skull': ((0.01, 0, 0.04), (0, -0.05, 0), (0, 0.05, 0), (-0.1, 0, 0.02))}
19+
"torso": (
20+
(-0.25, 0, 0.13),
21+
(-0.1, 0, 0.13),
22+
(0.05, 0, 0.15),
23+
(-0.25, -0.06, -0.01),
24+
(-0.1, -0.08, -0.02),
25+
(0.05, -0.09, -0.02),
26+
(-0.25, 0.06, -0.01),
27+
(-0.1, 0.08, -0.02),
28+
(0.05, 0.09, -0.02),
29+
),
30+
"C_6": ((0.05, -0.05, 0), (0.05, 0.05, 0)),
31+
"upper_arm": ((0.04, 0, 0)),
32+
"lower_arm": ((0.025, 0, 0), (0.025, 0, -0.1)),
33+
"hand": ((0, -0.02, 0), (0, 0.02, 0), (0.02, -0.02, -0.08), (0.02, 0.02, -0.08)),
34+
"finger": ((0.065, 0, 0)),
35+
"pelvis": ((0.04, -0.07, 0.02), (0.04, 0.07, 0.02)),
36+
"upper_leg": ((-0.03, 0.04, 0)),
37+
"lower_leg": ((0.04, 0, 0), (-0.04, 0.035, 0)),
38+
"foot": ((0, -0.02, 0), (0, 0.02, 0), (0, -0.02, -0.1), (0, 0.03, -0.1)),
39+
"toe": ((0.055, 0, 0)),
40+
"Ca_10": ((0, 0, 0.01)),
41+
"skull": ((0.01, 0, 0.04), (0, -0.05, 0), (0, 0.05, 0), (-0.1, 0, 0.02)),
42+
}
43+
3544

3645
def add_markers(model):
37-
bodies = model.find_all('body')
38-
39-
TOTAL_MARKERS = 0
40-
for body in bodies:
41-
for name, markers_pos in markers_per_body.items():
42-
if name in body.name and 'anchor' not in body.name:
43-
marker_idx = 0
44-
for pos in markers_pos:
45-
if '_R' in body.name:
46-
pos[1] *= -1
47-
body.add("site", name='marker_' + body.name + '_' + str(marker_idx),
48-
pos=pos, dclass="marker")
49-
50-
marker_idx += 1
51-
TOTAL_MARKERS += 1
52-
53-
for i in range(50):
54-
marker_body = model.worldbody.add('body', name="marker_" + str(i), mocap=True)
55-
marker_body.add('site', name="marker_" + str(i), dclass="mocap_marker")
56-
57-
print("TOTAL MARKERS ADDED:", TOTAL_MARKERS)
46+
"""Add markers to the given model.
47+
48+
Args:
49+
model: The model to add markers to.
50+
51+
Returns:
52+
None
53+
"""
54+
bodies = model.find_all("body")
55+
56+
total_markers = 0
57+
for body in bodies:
58+
for name, markers_pos in MARKERS_PER_BODY.items():
59+
if name in body.name and "anchor" not in body.name:
60+
marker_idx = 0
61+
for pos in markers_pos:
62+
if "_R" in body.name:
63+
pos[1] *= -1
64+
body.add(
65+
"site",
66+
name="marker_" + body.name + "_" + str(marker_idx),
67+
pos=pos,
68+
dclass="marker",
69+
)
70+
71+
marker_idx += 1
72+
total_markers += 1
73+
74+
for i in range(total_markers):
75+
marker_body = model.worldbody.add("body", name="marker_" + str(i), mocap=True)
76+
marker_body.add("site", name="marker_" + str(i), dclass="mocap_marker")

0 commit comments

Comments
 (0)