docs.unity3d.com
    Show / Hide Table of Contents

    Class RayPerceptionSensor

    A sensor implementation that supports ray cast-based observations.

    Inheritance
    Object
    RayPerceptionSensor
    Namespace: Unity.MLAgents.Sensors
    Syntax
    public class RayPerceptionSensor : object, ISensor

    Constructors

    RayPerceptionSensor(String, RayPerceptionInput)

    Creates the RayPerceptionSensor.

    Declaration
    public RayPerceptionSensor(string name, RayPerceptionInput rayInput)
    Parameters
    Type Name Description
    String name

    The name of the sensor.

    RayPerceptionInput rayInput

    The inputs for the sensor.

    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
    public virtual byte[] GetCompressedObservation()
    Returns
    Type Description
    Byte[]

    Compressed observation.

    Implements
    ISensor.GetCompressedObservation()

    GetCompressionType()

    Return the compression type being used. If no compression is used, return None.

    Declaration
    public virtual SensorCompressionType GetCompressionType()
    Returns
    Type Description
    SensorCompressionType

    Compression type used by the sensor.

    Implements
    ISensor.GetCompressionType()

    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
    public string GetName()
    Returns
    Type Description
    String

    The name of the sensor.

    Implements
    ISensor.GetName()

    GetObservationShape()

    Returns the size of the observations that will be generated. For example, a sensor that observes the velocity of a rigid body (in 3D) would return new {3}. A sensor that returns an RGB image would return new [] {Height, Width, 3}

    Declaration
    public int[] GetObservationShape()
    Returns
    Type Description
    Int32[]

    Size of the observations that will be generated.

    Implements
    ISensor.GetObservationShape()

    Perceive(RayPerceptionInput)

    Evaluates the raycasts to be used as part of an observation of an agent.

    Declaration
    public static RayPerceptionOutput Perceive(RayPerceptionInput input)
    Parameters
    Type Name Description
    RayPerceptionInput input

    Input defining the rays that will be cast.

    Returns
    Type Description
    RayPerceptionOutput

    Output struct containing the raycast results.

    Reset()

    Resets the internal states of the sensor. This is called at the end of an Agent's episode. Most implementations can leave this empty.

    Declaration
    public void Reset()
    Implements
    ISensor.Reset()

    Update()

    Update any internal state of the sensor. This is called once per each agent step.

    Declaration
    public void Update()
    Implements
    ISensor.Update()

    Write(ObservationWriter)

    Computes the ray perception observations and saves them to the provided ObservationWriter.

    Declaration
    public int Write(ObservationWriter writer)
    Parameters
    Type Name Description
    ObservationWriter writer

    Where the ray perception observations are written to.

    Returns
    Type Description
    Int32
    Implements
    ISensor.Write(ObservationWriter)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023