Interface ISensor
Sensor interface for generating observations.
Namespace: Unity.MLAgents.Sensors
Syntax
public interface ISensor
Methods
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.
Declaration
byte[] GetCompressedObservation()
Returns
Type | Description |
---|---|
Byte[] | Compressed observation. |
GetCompressionSpec()
Return information on the compression type being used. If no compression is used, return Default().
Declaration
CompressionSpec GetCompressionSpec()
Returns
Type | Description |
---|---|
CompressionSpec | An object describing the compression used by the sensor. |
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.
Declaration
string GetName()
Returns
Type | Description |
---|---|
String | The name of the sensor. |
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.
Declaration
ObservationSpec GetObservationSpec()
Returns
Type | Description |
---|---|
ObservationSpec | An object describing the observation. |
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.
Declaration
void Reset()
Update()
Update any internal state of the sensor. This is called once per each agent step.
Declaration
void Update()
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.
Declaration
int Write(ObservationWriter writer)
Parameters
Type | Name | Description |
---|---|---|
ObservationWriter | writer | Where the observations will be written to. |
Returns
Type | Description |
---|---|
Int32 | The number of elements written. |