Skip to content




class Preprocessor(abc.ABC)


Represents a preprocessor that transforms data from a sensor or another preprocessor to the input of agents or other preprocessors. The user of this class needs to implement the process method and the user is also required to set the below attributes:


input_uuids : List of input universally unique ids. uuid : Universally unique id. observation_space : gym.Space object corresponding to processed observation spaces.


 | @abc.abstractmethod
 | process(obs: Dict[str, Any], *args: Any, **kwargs: Any) -> Any


Returns processed observations from sensors or other preprocessors.


  • obs : Dict with available observations and processed observations.


Processed observation.


class SensorPreprocessorGraph()


Represents a graph of preprocessors, with each preprocessor being identified through a universally unique id.

Allows for the construction of observations that are a function of sensor readings. For instance, perhaps rather than giving your agent a raw RGB image, you'd rather first pass that image through a pre-trained convolutional network and only give your agent the resulting features (see e.g. the ResNetPreprocessor class).


  • preprocessors: List containing preprocessors with required input uuids, output uuid of each sensor must be unique.
  • observation_spaces: The observation spaces of the values returned when calling get_observations. By default (see the additionally_exposed_uuids parameter to to change this default) the observations returned by the SensorPreprocessorGraph include only the sink nodes of the graph (i.e. those that are not used by any other preprocessor). Thus if one of the input preprocessors takes as input the 'YOUR_SENSOR_UUID' sensor, then 'YOUR_SENSOR_UUID' will not be returned when calling get_observations.
  • device: The torch.device upon which the preprocessors are run.


 | __init__(source_observation_spaces: SpaceDict, preprocessors: Sequence[Union[Preprocessor, Builder[Preprocessor]]], additional_output_uuids: Sequence[str] = tuple()) -> None




  • source_observation_spaces : The observation spaces of all sensors before preprocessing. This generally should be the output of SensorSuite.observation_spaces.
  • preprocessors : The preprocessors that will be included in the graph.
  • additional_output_uuids: As described in the documentation for this class, the observations returned when calling get_observations only include, by default, those observations that are not processed by any preprocessor. If you'd like to include observations that would otherwise not be included, the uuids of these sensors should be included as a sequence of strings here.


 | get(uuid: str) -> Preprocessor


Return preprocessor with the given uuid.


  • uuid : The unique id of the preprocessor.


The preprocessor with unique id uuid.


 | get_observations(obs: Dict[str, Any], *args: Any, **kwargs: Any) -> Dict[str, Any]


Get processed observations.


Collect observations processed from all sensors and return them packaged inside a Dict.