-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add enum for sensor implementations, send in analytics #4871
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
namespace Unity.MLAgents.Sensors | ||
{ | ||
/// <summary> | ||
/// Identifiers for "built in" sensor types. | ||
/// These are only used for analytics, and should not be used for any runtime decisions. | ||
/// | ||
/// NOTE: Do not renumber these, since the values are used for analytics. Renaming is allowed though. | ||
/// </summary> | ||
public enum BuiltInSensorType | ||
{ | ||
Unknown = 0, | ||
VectorSensor = 1, | ||
// Note that StackingSensor actually returns the wrapped sensor's type | ||
StackingSensor = 2, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can omit this if you don't like it here (since it's not actually used). |
||
RayPerceptionSensor = 3, | ||
ReflectionSensor = 4, | ||
CameraSensor = 5, | ||
RenderTextureSensor = 6, | ||
BufferSensor = 7, | ||
PhysicsBodySensor = 8, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ordering doesn't actually matter here, but I could make the extensions implementations start at some offset, say 1000. |
||
Match3Sensor = 9, | ||
GridSensor = 10 | ||
} | ||
|
||
/// <summary> | ||
/// Interface for sensors that are provided as part of ML-Agents. | ||
/// User-implemented sensors don't need to use this interface. | ||
/// </summary> | ||
public interface IBuiltInSensor | ||
{ | ||
/// <summary> | ||
/// Return the corresponding BuiltInSensorType for the sensor. | ||
/// </summary> | ||
/// <returns>A BuiltInSensorType corresponding to the sensor.</returns> | ||
BuiltInSensorType GetBuiltInSensorType(); | ||
} | ||
|
||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ namespace Unity.MLAgents.Sensors | |
/// Internally, a circular buffer of arrays is used. The m_CurrentIndex represents the most recent observation. | ||
/// Currently, observations are stacked on the last dimension. | ||
/// </summary> | ||
public class StackingSensor : ISparseChannelSensor | ||
public class StackingSensor : ISparseChannelSensor, IBuiltInSensor | ||
{ | ||
/// <summary> | ||
/// The wrapped sensor. | ||
|
@@ -282,5 +282,12 @@ internal int[] ConstructStackedCompressedChannelMapping(ISensor wrappedSenesor) | |
} | ||
return compressionMapping; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public BuiltInSensorType GetBuiltInSensorType() | ||
{ | ||
IBuiltInSensor wrappedBuiltInSensor = m_WrappedSensor as IBuiltInSensor; | ||
return wrappedBuiltInSensor?.GetBuiltInSensorType() ?? BuiltInSensorType.Unknown; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO add unit test that checks this explicitly. |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll need to use version 2 here, waiting to hear back from analytics team.