(self)
return vel_reward
Get the velocity reward.
Get the velocity reward.
Get the velocity reward .
def _calc_reward_velocity(self):
    """Get the velocity reward."""
    env = self._env
    robot = env.robot
    sim_model = robot.quadruped
    ref_model = self._ref_model
    pyb = self._get_pybullet_client()

    vel_err = 0.0
    num_joints = self._get_num_joints()

    for j in range(num_joints):
      j_state_ref = pyb.getJointStateMultiDof(ref_model, j)
      j_state_sim = pyb.getJointStateMultiDof(sim_model, j)
      j_vel_ref = np.array(j_state_ref[1])
      j_vel_sim = np.array(j_state_sim[1])

      j_size_ref = len(j_vel_ref)
      j_size_sim = len(j_vel_sim)

      if (j_size_ref > 0):
        assert (j_size_sim == j_size_ref)
        j_vel_diff = j_vel_ref - j_vel_sim
        j_vel_err = j_vel_diff.dot(j_vel_diff)
        vel_err += j_vel_err

    vel_reward = np.exp(-self._velocity_err_scale * vel_err)

    return vel_reward
def _calc_reward_velocity ( self ) : env = self . _env robot = env . robot sim_model = robot . quadruped ref_model = self . _ref_model pyb = self . _get_pybullet_client ( ) vel_err = 0.0 num_joints = self . _get_num_joints ( ) for j in range ( num_joints ) : j_state_ref = pyb . getJointStateMultiDof ( ref_model , j ) j_state_sim = pyb . getJointStateMultiDof ( sim_model , j ) j_vel_ref = np . array ( j_state_ref [ 1 ] ) j_vel_sim = np . array ( j_state_sim [ 1 ] ) j_size_ref = len ( j_vel_ref ) j_size_sim = len ( j_vel_sim ) if ( j_size_ref > 0 ) : assert ( j_size_sim == j_size_ref ) j_vel_diff = j_vel_ref - j_vel_sim j_vel_err = j_vel_diff . dot ( j_vel_diff ) vel_err += j_vel_err vel_reward = np . exp ( - self . _velocity_err_scale * vel_err ) return vel_reward