浏览代码

addressing comments

/goal-conditioning/sensors-2
vincentpierre 4 年前
当前提交
71eceeab
共有 4 个文件被更改,包括 23 次插入4 次删除
  1. 1
      com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs
  2. 9
      com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs
  3. 15
      com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs
  4. 2
      com.unity.ml-agents/Tests/Editor/Sensor/VectorSensorTests.cs

1
com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs


{
// These fields affect the sensor order or observation size,
// So can't be changed at runtime.
EditorGUILayout.PropertyField(so.FindProperty("m_SensorName"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_observationSize"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_ObservationType"), true);
}

9
com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs


/// </summary>
/// <param name="observationSize">Number of vector observations.</param>
/// <param name="name">Name of the sensor.</param>
public VectorSensor(int observationSize, string name = null, ObservationType observationType = ObservationType.Default)
public VectorSensor(int observationSize, ObservationType observationType = ObservationType.Default, string name = null)
if (name == null)
if (name == null || name == "")
if (observationType != ObservationType.Default)
{
name += "_goal";
}
m_Observations = new List<float>(observationSize);
m_Name = name;

15
com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs


[AddComponentMenu("ML Agents/Vector Sensor", (int)MenuGroup.Sensors)]
public class VectorSensorComponent : SensorComponent
{
/// <summary>
/// Name of the generated <see cref="VectorSensor"/> object.
/// Note that changing this at runtime does not affect how the Agent sorts the sensors.
/// </summary>
public string SensorName
{
get { return m_SensorName; }
set { m_SensorName = value; }
}
[HideInInspector, SerializeField]
private string m_SensorName = "VectorSensor";
public int ObservationSize
{
get { return m_observationSize; }

/// <returns></returns>
public override ISensor CreateSensor()
{
m_sensor = new VectorSensor(m_observationSize, observationType: m_ObservationType);
m_sensor = new VectorSensor(m_observationSize, m_ObservationType, m_SensorName);
return m_sensor;
}

2
com.unity.ml-agents/Tests/Editor/Sensor/VectorSensorTests.cs


ISensor sensor = new VectorSensor(4);
Assert.AreEqual("VectorSensor_size4", sensor.GetName());
sensor = new VectorSensor(3, "test_sensor");
sensor = new VectorSensor(3, name: "test_sensor");
Assert.AreEqual("test_sensor", sensor.GetName());
}

正在加载...
取消
保存