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

Function rescale_subtree

dm_control/locomotion/walkers/rescale.py:21–36  ·  view source on GitHub ↗

Recursively rescales an entire subtree of an MJCF model.

(body, position_factor, size_factor)

Source from the content-addressed store, hash-verified

19
20
21def rescale_subtree(body, position_factor, size_factor):
22 """Recursively rescales an entire subtree of an MJCF model."""
23 for child in body.all_children():
24 if child.tag == 'sensor':
25 continue
26 if getattr(child, 'fromto', None) is not None:
27 new_pos = position_factor * 0.5 * (child.fromto[3:] + child.fromto[:3])
28 new_size = size_factor * 0.5 * (child.fromto[3:] - child.fromto[:3])
29 child.fromto[:3] = new_pos - new_size
30 child.fromto[3:] = new_pos + new_size
31 if getattr(child, 'pos', None) is not None:
32 child.pos *= position_factor
33 if getattr(child, 'size', None) is not None:
34 child.size *= size_factor
35 if child.tag == 'body' or child.tag == 'worldbody':
36 rescale_subtree(child, position_factor, size_factor)
37
38
39def rescale_humanoid(walker, position_factor, size_factor=None, mass=None):

Callers 1

rescale_humanoidFunction · 0.85

Calls 1

all_childrenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…