MCPcopy Create free account
hub / github.com/google-deepmind/dm_control / rescale_humanoid

Function rescale_humanoid

dm_control/locomotion/walkers/rescale.py:39–60  ·  view source on GitHub ↗

Rescales a humanoid walker's lengths, sizes, and masses.

(walker, position_factor, size_factor=None, mass=None)

Source from the content-addressed store, hash-verified

37
38
39def rescale_humanoid(walker, position_factor, size_factor=None, mass=None):
40 """Rescales a humanoid walker's lengths, sizes, and masses."""
41 body = walker.mjcf_model.find('body', 'root')
42 subtree_root = body.parent
43 if size_factor is None:
44 size_factor = position_factor
45 rescale_subtree(subtree_root, position_factor, size_factor)
46
47 if mass is not None:
48 physics = mjcf.Physics.from_mjcf_model(walker.mjcf_model.root_model)
49 current_mass = physics.bind(walker.root_body).subtreemass
50 mass_factor = mass / current_mass
51 for body in walker.root_body.find_all('body'):
52 inertial = getattr(body, 'inertial', None)
53 if inertial:
54 inertial.mass *= mass_factor
55 for geom in walker.root_body.find_all('geom'):
56 if geom.mass is not None:
57 geom.mass *= mass_factor
58 else:
59 current_density = geom.density if geom.density is not None else 1000
60 geom.density = current_density * mass_factor

Callers

nothing calls this directly

Calls 5

rescale_subtreeFunction · 0.85
from_mjcf_modelMethod · 0.80
findMethod · 0.45
bindMethod · 0.45
find_allMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…