(walker, position_factor, size_factor=None, mass=None)
Rescales a humanoid walker's lengths, sizes, and masses.
Rescales a humanoid walker's lengths, sizes, and masses.
Rescales a humanoid walker s lengths sizes and masses .
def rescale_humanoid(walker, position_factor, size_factor=None, mass=None):
  """Rescales a humanoid walker's lengths, sizes, and masses."""
  body = walker.mjcf_model.find('body', 'root')
  subtree_root = body.parent
  if size_factor is None:
    size_factor = position_factor
  rescale_subtree(subtree_root, position_factor, size_factor)

  if mass is not None:
    physics = mjcf.Physics.from_mjcf_model(walker.mjcf_model.root_model)
    current_mass = physics.bind(walker.root_body).subtreemass
    mass_factor = mass / current_mass
    for body in walker.root_body.find_all('body'):
      inertial = getattr(body, 'inertial', None)
      if inertial:
        inertial.mass *= mass_factor
    for geom in walker.root_body.find_all('geom'):
      if geom.mass is not None:
        geom.mass *= mass_factor
      else:
        current_density = geom.density if geom.density is not None else 1000
        geom.density = current_density * mass_factor
def rescale_humanoid ( walker , position_factor , size_factor = None , mass = None ) : body = walker . mjcf_model . find ( 'body' , 'root' ) subtree_root = body . parent if size_factor is None : size_factor = position_factor rescale_subtree ( subtree_root , position_factor , size_factor ) if mass is not None : physics = mjcf . Physics . from_mjcf_model ( walker . mjcf_model . root_model ) current_mass = physics . bind ( walker . root_body ) . subtreemass mass_factor = mass / current_mass for body in walker . root_body . find_all ( 'body' ) : inertial = getattr ( body , 'inertial' , None ) if inertial : inertial . mass *= mass_factor for geom in walker . root_body . find_all ( 'geom' ) : if geom . mass is not None : geom . mass *= mass_factor else : current_density = geom . density if geom . density is not None else 1000 geom . density = current_density * mass_factor