-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Adding the goal conditioning sensors with the new observation specs #5159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
19069cc
Fixing networks.py for the merge
vincentpierre f15a529
fix compile error
570df7f
Adding the goal conditioning sensors with the new observation specs
vincentpierre 63fb8b7
Merge branch 'main' into goal-conditioning-sensors-3
vincentpierre 7388bc5
addressing feedback
vincentpierre feba34b
I forgot to change the m_observationType
vincentpierre 82e20b7
Renaming Goal to GoalSignal (#5190)
vincentpierre ddf9cbd
Merge branch 'main' into goal-conditioning-sensors-3
vincentpierre 17e3863
Renaming GOAL to GOAL_SIGNAL
vincentpierre 6043a49
VectorSensorComponent to use new API
vincentpierre d288502
Adding docstrings
vincentpierre 69505c2
verbose pytest on github action
vincentpierre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||
vincentpierre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
/// <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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.