比较提交

...
此合并请求有变更与目标分支冲突。
/com.unity.ml-agents/Editor/CameraSensorComponentEditor.cs
/com.unity.ml-agents/Runtime/Sensors/CameraSensor.cs
/com.unity.ml-agents/Runtime/Sensors/CameraSensorComponent.cs
/com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs
/ml-agents-envs/mlagents_envs/base_env.py
/com.unity.ml-agents/Tests/Editor/Sensor/VectorSensorTests.cs
/com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs
/com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs.meta
/com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs
/com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs.meta
/com.unity.ml-agents/Runtime/Sensors/ITypedSensor.cs

5 次代码提交

作者 SHA1 备注 提交日期
vincentpierre 19386a44 Removing the Reward and Message Observation Type, will readd when used 4 年前
vincentpierre f80f7651 minor edits 4 年前
vincentpierre 71eceeab addressing comments 4 年前
vincentpierre 22c51ec6 Removing VectorSensor UpdateSensor method 4 年前
vincentpierre b293dd9e Adding The sensors for goal conditioning 4 年前
共有 11 个文件被更改,包括 169 次插入17 次删除
  1. 1
      com.unity.ml-agents/Editor/CameraSensorComponentEditor.cs
  2. 2
      com.unity.ml-agents/Tests/Editor/Sensor/VectorSensorTests.cs
  3. 14
      com.unity.ml-agents/Runtime/Sensors/CameraSensorComponent.cs
  4. 19
      com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs
  5. 24
      com.unity.ml-agents/Runtime/Sensors/CameraSensor.cs
  6. 8
      com.unity.ml-agents/Runtime/Sensors/ITypedSensor.cs
  7. 4
      ml-agents-envs/mlagents_envs/base_env.py
  8. 11
      com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs.meta
  9. 30
      com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs
  10. 62
      com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs
  11. 11
      com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs.meta

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


EditorGUILayout.PropertyField(so.FindProperty("m_Height"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_Grayscale"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_ObservationStacks"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_ObservationType"), true);
}
EditorGUI.EndDisabledGroup();
EditorGUILayout.PropertyField(so.FindProperty("m_Compression"), true);

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());
}

14
com.unity.ml-agents/Runtime/Sensors/CameraSensorComponent.cs


set { m_SensorName = value; }
}
[HideInInspector, SerializeField]
ObservationType m_ObservationType;
[HideInInspector, SerializeField, FormerlySerializedAs("width")]
int m_Width = 84;

}
/// <summary>
/// The type of the observation.
/// </summary>
public ObservationType SensorObservationType
{
get { return m_ObservationType; }
set { m_ObservationType = value; UpdateSensor(); }
}
/// <summary>
m_Sensor = new CameraSensor(m_Camera, m_Width, m_Height, Grayscale, m_SensorName, m_Compression);
m_Sensor = new CameraSensor(m_Camera, m_Width, m_Height, Grayscale, m_SensorName, m_Compression, m_ObservationType);
if (ObservationStacks != 1)
{

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


/// <summary>
/// A sensor implementation for vector observations.
/// </summary>
public class VectorSensor : ISensor, IBuiltInSensor
public class VectorSensor : ISensor, ITypedSensor, IBuiltInSensor
{
// TODO use float[] instead
// TODO allow setting float[]

ObservationType m_ObservationType;
/// <summary>
/// Initializes the sensor.

public VectorSensor(int observationSize, string name = null)
public VectorSensor(int observationSize, string name = null, ObservationType observationType = ObservationType.Default)
if (name == null)
if (name == null || name == "")
if (observationType != ObservationType.Default)
{
name += "_goal";
}
m_ObservationType = observationType;
}
/// <inheritdoc/>

public int[] GetObservationShape()
{
return m_Shape;
}
/// <inheritdoc/>
public virtual ObservationType GetObservationType()
{
return m_ObservationType;
}
/// <inheritdoc/>

24
com.unity.ml-agents/Runtime/Sensors/CameraSensor.cs


/// <summary>
/// A sensor that wraps a Camera object to generate visual observations for an agent.
/// </summary>
public class CameraSensor : ISensor, IBuiltInSensor, IDimensionPropertiesSensor
public class CameraSensor : ISensor, ITypedSensor, IBuiltInSensor, IDimensionPropertiesSensor
{
Camera m_Camera;
int m_Width;

int[] m_Shape;
SensorCompressionType m_CompressionType;
ObservationType m_ObservationType;
static DimensionProperty[] s_DimensionProperties = new DimensionProperty[] {
DimensionProperty.TranslationalEquivariance,
DimensionProperty.TranslationalEquivariance,

set { m_CompressionType = value; }
}
public ObservationType ObservationType
{
get { return m_ObservationType; }
set { m_ObservationType = value; }
}
/// <summary>
/// Creates and returns the camera sensor.

/// <param name="name">The name of the camera sensor.</param>
/// <param name="compression">The compression to apply to the generated image.</param>
public CameraSensor(
Camera camera, int width, int height, bool grayscale, string name, SensorCompressionType compression)
Camera camera,
int width,
int height,
bool grayscale,
string name,
SensorCompressionType compression,
ObservationType observationType = ObservationType.Default)
{
m_Camera = camera;
m_Width = width;

m_Shape = GenerateShape(width, height, grayscale);
m_CompressionType = compression;
m_ObservationType = observationType;
}
/// <summary>

public string GetName()
{
return m_Name;
}
/// <inheritdoc/>
public virtual ObservationType GetObservationType()
{
return m_ObservationType;
}
/// <summary>

8
com.unity.ml-agents/Runtime/Sensors/ITypedSensor.cs


/// <summary>
/// The ObservationType enum of the Sensor.
/// </summary>
internal enum ObservationType
public enum ObservationType
// Collected observations contain reward information.
Reward = 2,
// Collected observations are messages from other agents.
Message = 3,
}

internal interface ITypedSensor
public interface ITypedSensor
{
/// <summary>
/// Returns the ObservationType enum corresponding to the type of the sensor.

4
ml-agents-envs/mlagents_envs/base_env.py


DEFAULT = 0
# Observation contains goal information for current task.
GOAL = 1
# Observation contains reward information for current task.
REWARD = 2
# Observation contains a message from another agent.
MESSAGE = 3
class ObservationSpec(NamedTuple):

11
com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs.meta


fileFormatVersion: 2
guid: 4e900f9ce9be541c69e45ae94956932f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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


using UnityEditor;
using Unity.MLAgents.Sensors;
namespace Unity.MLAgents.Editor
{
[CustomEditor(typeof(VectorSensorComponent))]
[CanEditMultipleObjects]
internal class VectorSensorComponentEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
var so = serializedObject;
so.Update();
// Drawing the VectorSensorComponent
EditorGUI.BeginDisabledGroup(!EditorUtilities.CanUpdateModelProperties());
{
// 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);
}
EditorGUI.EndDisabledGroup();
so.ApplyModifiedProperties();
}
}
}

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


using UnityEngine;
using UnityEngine.Serialization;
namespace Unity.MLAgents.Sensors
{
[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; }
set { m_observationSize = value; }
}
[HideInInspector, SerializeField]
int m_observationSize;
[HideInInspector, SerializeField]
ObservationType m_ObservationType;
VectorSensor m_sensor;
public ObservationType ObservationType
{
get { return m_ObservationType; }
set { m_ObservationType = value; }
}
/// <summary>
/// Creates a VectorSensor.
/// </summary>
/// <returns></returns>
public override ISensor CreateSensor()
{
m_sensor = new VectorSensor(m_observationSize, m_SensorName, m_ObservationType);
return m_sensor;
}
/// <inheritdoc/>
public override int[] GetObservationShape()
{
return new[] { m_observationSize };
}
public VectorSensor GetSensor()
{
return m_sensor;
}
}
}

11
com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs.meta


fileFormatVersion: 2
guid: 58239d05cfbbd4ac1b22ba12865beca3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存