Search Unity

AddObservation() for Ray Perception Sensor component?

Discussion in 'ML-Agents' started by Roboserg, Dec 30, 2020.

  1. Roboserg

    Roboserg

    Joined:
    Jun 3, 2018
    Posts:
    83
    when using the Ray Perception Sensor component on the game object of an agent, do I have to AddObservation() in the agent script as well, or does it do it automatically? Unity ml agents examples do NOT use AddObservation() for rays but I want to ask to be sure.

    Also about the vector observation space size, do I have to adjust its size based on the number of rays? Or does it do it automatically for rays?
     
  2. mbaske

    mbaske

    Joined:
    Dec 31, 2017
    Posts:
    473
    AFAIK CollectObservations(VectorSensor sensor) is only called for vector observations. Setting the vector observation space size to 0 means you don't want to use a vector sensor and hence don't need to implement CollectObservations and AddObservation. Ray perception and other sensors are resposible for writing their own observations, independent of the vector observation space size. If you're mixing sensors, then you only need to call AddObservation for your vector observations.