Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(so.FindProperty("m_SensorName"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_ObservationSize"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_ObservationType"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_ObservationStacks"), true);
}
EditorGUI.EndDisabledGroup();

Expand Down
19 changes: 19 additions & 0 deletions com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,32 @@ public ObservationType ObservationType
set { m_ObservationType = value; }
}

[HideInInspector, SerializeField]
[Range(1, 50)]
[Tooltip("Number of camera frames that will be stacked before being fed to the neural network.")]
int m_ObservationStacks = 1;

/// <summary>
/// Whether to stack previous observations. Using 1 means no previous observations.
/// Note that changing this after the sensor is created has no effect.
/// </summary>
public int ObservationStacks
{
get { return m_ObservationStacks; }
set { m_ObservationStacks = value; }
}

/// <summary>
/// Creates a VectorSensor.
/// </summary>
/// <returns></returns>
public override ISensor[] CreateSensors()
{
m_Sensor = new VectorSensor(m_ObservationSize, m_SensorName, m_ObservationType);
if (ObservationStacks != 1)
{
return new ISensor[] { new StackingSensor(m_Sensor, ObservationStacks) };
}
return new ISensor[] { m_Sensor };
}

Expand Down