-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the goal conditioning sensors with the new observation specs (#…
…5159) * Fixing networks.py for the merge * fix compile error * Adding the goal conditioning sensors with the new observation specs * addressing feedback * I forgot to change the m_observationType * Renaming Goal to GoalSignal (#5190) * Renaming GOAL to GOAL_SIGNAL * VectorSensorComponent to use new API * Adding docstrings * verbose pytest on github action Co-authored-by: Chris Elion <chris.elion@unity3d.com>
- Loading branch information
1 parent
2072dd2
commit ca0fca7
Showing
19 changed files
with
194 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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(); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using UnityEngine; | ||
using UnityEngine.Serialization; | ||
|
||
namespace Unity.MLAgents.Sensors | ||
{ | ||
/// <summary> | ||
/// A SensorComponent that creates a <see cref="VectorSensor"/>. | ||
/// </summary> | ||
[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"; | ||
|
||
/// <summary> | ||
/// The number of float observations in the VectorSensor | ||
/// </summary> | ||
public int ObservationSize | ||
{ | ||
get { return m_ObservationSize; } | ||
set { m_ObservationSize = value; } | ||
} | ||
|
||
[HideInInspector, SerializeField] | ||
int m_ObservationSize; | ||
|
||
[HideInInspector, SerializeField] | ||
ObservationType m_ObservationType; | ||
|
||
VectorSensor m_Sensor; | ||
|
||
/// <summary> | ||
/// The type of the observation. | ||
/// </summary> | ||
public ObservationType ObservationType | ||
{ | ||
get { return m_ObservationType; } | ||
set { m_ObservationType = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Creates a VectorSensor. | ||
/// </summary> | ||
/// <returns></returns> | ||
public override ISensor[] CreateSensors() | ||
{ | ||
m_Sensor = new VectorSensor(m_ObservationSize, m_SensorName, m_ObservationType); | ||
return new ISensor[] { m_Sensor }; | ||
} | ||
|
||
/// <summary> | ||
/// Returns the underlying VectorSensor | ||
/// </summary> | ||
public VectorSensor GetSensor() | ||
{ | ||
return m_Sensor; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 4 additions & 14 deletions
18
ml-agents-envs/mlagents_envs/communicator_objects/observation_pb2.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.