(self, walker)
Rescales a given walker to match the data in this `WalkerInfo`.
Rescales a given walker to match the data in this `WalkerInfo`.
Rescales a given walker to match the data in this WalkerInfo .
def rescale_walker(self, walker):
    """Rescales a given walker to match the data in this `WalkerInfo`."""
    self.check_walker_is_compatible(walker)
    for subtree_info in self._proto.scaling.subtree:
      body = walker.mjcf_model.find('body', subtree_info.body_name)
      subtree_root = body.parent
      if subtree_info.parent_length:
        position_factor = subtree_info.parent_length / np.linalg.norm(body.pos)
      else:
        position_factor = subtree_info.size_factor
      rescale.rescale_subtree(
          subtree_root, position_factor, subtree_info.size_factor)

    if self._proto.mass:
      physics = mjcf.Physics.from_mjcf_model(walker.mjcf_model.root_model)
      current_mass = physics.bind(walker.root_body).subtreemass
      mass_factor = self._proto.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_walker ( self , walker ) : self . check_walker_is_compatible ( walker ) for subtree_info in self . _proto . scaling . subtree : body = walker . mjcf_model . find ( 'body' , subtree_info . body_name ) subtree_root = body . parent if subtree_info . parent_length : position_factor = subtree_info . parent_length / np . linalg . norm ( body . pos ) else : position_factor = subtree_info . size_factor rescale . rescale_subtree ( subtree_root , position_factor , subtree_info . size_factor ) if self . _proto . mass : physics = mjcf . Physics . from_mjcf_model ( walker . mjcf_model . root_model ) current_mass = physics . bind ( walker . root_body ) . subtreemass mass_factor = self . _proto . 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