Class GridSensorBase
Grid-based sensor.
Inherited Members
Namespace: Unity.MLAgents.Sensors
Assembly: solution.dll
Syntax
public class GridSensorBase : ISensor, IDisposable
Constructors
| Name | Description |
|---|---|
| GridSensorBase(string, Vector3, Vector3Int, string[], SensorCompressionType) | Create a GridSensorBase with the specified configuration. |
Properties
| Name | Description |
|---|---|
| CompressionType | The compression type used by the sensor. |
| DetectableTags | The tags which the sensor dectects. |
Methods
| Name | Description |
|---|---|
| Dispose() | Clean up the internal objects. |
| GetBuiltInSensorType() | Return the corresponding BuiltInSensorType for the sensor. |
| GetCellObservationSize() | Get the observation size for each cell. This will be the size of dataBuffer for GetObjectData(GameObject, int, float[]). If overriding GetObjectData(GameObject, int, float[]), override this method as well to the custom observation size. |
| GetCompressedObservation() | Return a compressed representation of the observation. For small observations, this should generally not be implemented. However, compressing large observations (such as visual results) can significantly improve model training time. |
| GetCompressionSpec() | Return information on the compression type being used. If no compression is used, return Default(). |
| GetName() | Get the name of the sensor. This is used to ensure deterministic sorting of the sensors on an Agent, so the naming must be consistent across all sensors and agents. |
| GetObjectData(GameObject, int, float[]) | Get the observation values of the detected game object. Default is to record the detected tag index. This method can be overridden to encode the observation differently or get custom data from the object. When overriding this method, GetCellObservationSize() and IsDataNormalized() might also need to change accordingly. |
| GetObservationSpec() | Returns a description of the observations that will be generated by the sensor. See ObservationSpec for more details, and helper methods to create one. |
| GetProcessCollidersMethod() | Whether to process all detected colliders in a cell. Default to false and only use the one closest to the agent. If overriding GetObjectData(GameObject, int, float[]), consider override this method when needed. |
| IsDataNormalized() | Whether the data is normalized within [0, 1]. The sensor can only use PNG compression if the data is normailzed. If overriding GetObjectData(GameObject, int, float[]), override this method as well according to the custom observation values. |
| Reset() | Resets the internal state of the sensor. This is called at the end of an Agent's episode. Most implementations can leave this empty. |
| ResetPerceptionBuffer() | Clears the perception buffer before loading in new data. |
| Update() | Update any internal state of the sensor. This is called once per each agent step. |
| Write(ObservationWriter) | Write the observation data directly to the ObservationWriter. Note that this (and GetCompressedObservation()) may be called multiple times per agent step, so should not mutate any internal state. |