(physics, walker, props=None)
return walker_features
Get walker features for reward functions.
Get walker features for reward functions.
Get walker features for reward functions .
def get_features(physics, walker, props=None):
  """Get walker features for reward functions."""
  walker_bodies = walker.mocap_tracking_bodies

  walker_features = {}
  root_pos, root_quat = walker.get_pose(physics)
  walker_features['position'] = np.array(root_pos)
  walker_features['quaternion'] = np.array(root_quat)
  joints = np.array(physics.bind(walker.mocap_joints).qpos)
  walker_features['joints'] = joints
  freejoint_frame = mjcf.get_attachment_frame(walker.mjcf_model)

  com = np.array(physics.bind(freejoint_frame).subtree_com)
  walker_features['center_of_mass'] = com
  end_effectors = np.array(
      walker.observables.end_effectors_pos(physics)[:]).reshape(-1, 3)
  walker_features['end_effectors'] = end_effectors
  if hasattr(walker.observables, 'appendages_pos'):
    appendages = np.array(
        walker.observables.appendages_pos(physics)[:]).reshape(-1, 3)
  else:
    appendages = np.array(end_effectors)
  walker_features['appendages'] = appendages
  xpos = np.array(physics.bind(walker_bodies).xpos)
  walker_features['body_positions'] = xpos
  xquat = np.array(physics.bind(walker_bodies).xquat)
  walker_features['body_quaternions'] = xquat
  root_vel, root_angvel = walker.get_velocity(physics)
  walker_features['velocity'] = np.array(root_vel)
  walker_features['angular_velocity'] = np.array(root_angvel)
  joints_vel = np.array(physics.bind(walker.mocap_joints).qvel)
  walker_features['joints_velocity'] = joints_vel

  if props:
    positions = []
    quaternions = []
    for prop in props:
      pos, quat = prop.get_pose(physics)
      positions.append(pos)
      quaternions.append(quat)
    walker_features['prop_positions'] = np.array(positions)
    walker_features['prop_quaternions'] = np.array(quaternions)
  return walker_features
def get_features ( physics , walker , props = None ) : walker_bodies = walker . mocap_tracking_bodies walker_features = { } root_pos , root_quat = walker . get_pose ( physics ) walker_features [ 'position' ] = np . array ( root_pos ) walker_features [ 'quaternion' ] = np . array ( root_quat ) joints = np . array ( physics . bind ( walker . mocap_joints ) . qpos ) walker_features [ 'joints' ] = joints freejoint_frame = mjcf . get_attachment_frame ( walker . mjcf_model ) com = np . array ( physics . bind ( freejoint_frame ) . subtree_com ) walker_features [ 'center_of_mass' ] = com end_effectors = np . array ( walker . observables . end_effectors_pos ( physics ) [ : ] ) . reshape ( - 1 , 3 ) walker_features [ 'end_effectors' ] = end_effectors if hasattr ( walker . observables , 'appendages_pos' ) : appendages = np . array ( walker . observables . appendages_pos ( physics ) [ : ] ) . reshape ( - 1 , 3 ) else : appendages = np . array ( end_effectors ) walker_features [ 'appendages' ] = appendages xpos = np . array ( physics . bind ( walker_bodies ) . xpos ) walker_features [ 'body_positions' ] = xpos xquat = np . array ( physics . bind ( walker_bodies ) . xquat ) walker_features [ 'body_quaternions' ] = xquat root_vel , root_angvel = walker . get_velocity ( physics ) walker_features [ 'velocity' ] = np . array ( root_vel ) walker_features [ 'angular_velocity' ] = np . array ( root_angvel ) joints_vel = np . array ( physics . bind ( walker . mocap_joints ) . qvel ) walker_features [ 'joints_velocity' ] = joints_vel if props : positions = [ ] quaternions = [ ] for prop in props : pos , quat = prop . get_pose ( physics ) positions . append ( pos ) quaternions . append ( quat ) walker_features [ 'prop_positions' ] = np . array ( positions ) walker_features [ 'prop_quaternions' ] = np . array ( quaternions ) return walker_features