(self)
return {k: v[self._start_step:self._end_step]
            for k, v in self._dict.items()}
Return trajectory as dictionary.
Return trajectory as dictionary.
Return trajectory as dictionary .
def as_dict(self):
    """Return trajectory as dictionary."""
    if self._dict is None:
      self._dict = dict()

      if self._proto.timesteps:
        initial_timestep = self._proto.timesteps[0]

        num_walkers = len(initial_timestep.walkers)
        for i in range(num_walkers):
          key_prefix = 'walker_{:d}/'.format(
              i) if num_walkers > 1 else 'walker/'
          for field in mocap_pb2.WalkerPose.DESCRIPTOR.fields:
            field_name = field.name

            def walker_field(timestep, i=i, field_name=field_name):
              values = getattr(timestep.walkers[i], field_name)
              if field_name in _REPEATED_POSITION_FIELDS:
                values = np.reshape(values, (-1, 3))
              elif field_name in _REPEATED_QUATERNION_FIELDS:
                values = np.reshape(values, (-1, 4))
              return np.array(values)

            self._dict[key_prefix + field_name] = walker_field

        num_props = len(initial_timestep.props)
        for i in range(len(initial_timestep.props)):
          key_prefix = 'prop_{:d}/'.format(i) if num_props > 1 else 'prop/'
          for field in mocap_pb2.PropPose.DESCRIPTOR.fields:
            field_name = field.name

            def prop_field(timestep, i=i, field_name=field_name):
              return np.array(getattr(timestep.props[i], field_name))

            self._dict[key_prefix + field_name] = prop_field

        self._create_all_items(self._dict)
        for k in self._dict:
          # make trajectory immutable by default
          self._dict[k].flags.writeable = False  # pytype: disable=attribute-error

    return {k: v[self._start_step:self._end_step]
            for k, v in self._dict.items()}
def as_dict ( self ) : if self . _dict is None : self . _dict = dict ( ) if self . _proto . timesteps : initial_timestep = self . _proto . timesteps [ 0 ] num_walkers = len ( initial_timestep . walkers ) for i in range ( num_walkers ) : key_prefix = 'walker_{:d}/' . format ( i ) if num_walkers > 1 else 'walker/' for field in mocap_pb2 . WalkerPose . DESCRIPTOR . fields : field_name = field . name def walker_field ( timestep , i = i , field_name = field_name ) : values = getattr ( timestep . walkers [ i ] , field_name ) if field_name in _REPEATED_POSITION_FIELDS : values = np . reshape ( values , ( - 1 , 3 ) ) elif field_name in _REPEATED_QUATERNION_FIELDS : values = np . reshape ( values , ( - 1 , 4 ) ) return np . array ( values ) self . _dict [ key_prefix + field_name ] = walker_field num_props = len ( initial_timestep . props ) for i in range ( len ( initial_timestep . props ) ) : key_prefix = 'prop_{:d}/' . format ( i ) if num_props > 1 else 'prop/' for field in mocap_pb2 . PropPose . DESCRIPTOR . fields : field_name = field . name def prop_field ( timestep , i = i , field_name = field_name ) : return np . array ( getattr ( timestep . props [ i ] , field_name ) ) self . _dict [ key_prefix + field_name ] = prop_field self . _create_all_items ( self . _dict ) for k in self . _dict : # make trajectory immutable by default self . _dict [ k ] . flags . writeable = False # pytype: disable=attribute-error return { k : v [ self . _start_step : self . _end_step ] for k , v in self . _dict . items ( ) }