(self, physics)
Randomizes initial root velocities and actuator states.

    Args:
      physics: An instance of `Physics`.
Randomizes initial root velocities and actuator states.
Randomizes initial root velocities and actuator states .
def initialize_episode(self, physics):
    """Randomizes initial root velocities and actuator states.

    Args:
      physics: An instance of `Physics`.

    """
    physics.reset()

    # Measure stand heights from default pose, above which stand reward is 1.
    self._stand_height = physics.torso_pelvis_height() * _STAND_HEIGHT_FRACTION

    # Measure body weight.
    body_mass = physics.named.model.body_subtreemass['torso']
    self._body_weight = -physics.model.opt.gravity[2] * body_mass

    # Randomize horizontal orientation.
    azimuth = self.random.uniform(0, 2*np.pi)
    orientation = np.array((np.cos(azimuth/2), 0, 0, np.sin(azimuth/2)))
    physics.named.data.qpos['root'][3:] = orientation

    # Randomize root velocities in horizontal plane.
    physics.data.qvel[0] = 2 * self.random.randn()
    physics.data.qvel[1] = 2 * self.random.randn()
    physics.data.qvel[5] = 2 * self.random.randn()

    # Randomize actuator states.
    assert physics.model.nu == physics.model.na
    for actuator_id in range(physics.model.nu):
      ctrlrange = physics.model.actuator_ctrlrange[actuator_id]
      physics.data.act[actuator_id] = self.random.uniform(*ctrlrange)
def initialize_episode ( self , physics ) : physics . reset ( ) # Measure stand heights from default pose, above which stand reward is 1. self . _stand_height = physics . torso_pelvis_height ( ) * _STAND_HEIGHT_FRACTION # Measure body weight. body_mass = physics . named . model . body_subtreemass [ 'torso' ] self . _body_weight = - physics . model . opt . gravity [ 2 ] * body_mass # Randomize horizontal orientation. azimuth = self . random . uniform ( 0 , 2 * np . pi ) orientation = np . array ( ( np . cos ( azimuth / 2 ) , 0 , 0 , np . sin ( azimuth / 2 ) ) ) physics . named . data . qpos [ 'root' ] [ 3 : ] = orientation # Randomize root velocities in horizontal plane. physics . data . qvel [ 0 ] = 2 * self . random . randn ( ) physics . data . qvel [ 1 ] = 2 * self . random . randn ( ) physics . data . qvel [ 5 ] = 2 * self . random . randn ( ) # Randomize actuator states. assert physics . model . nu == physics . model . na for actuator_id in range ( physics . model . nu ) : ctrlrange = physics . model . actuator_ctrlrange [ actuator_id ] physics . data . act [ actuator_id ] = self . random . uniform ( * ctrlrange )