Mohsen Kamalzadeh
4 年前
当前提交
b694fb11
共有 14 个文件被更改,包括 83 次插入 和 81 次删除
-
4com.unity.perception/CHANGELOG.md
-
4com.unity.perception/Documentation~/Tutorial/Phase1.md
-
28com.unity.perception/Editor/Randomization/Editors/RunInUnitySimulationWindow.cs
-
2com.unity.perception/Editor/Randomization/Uxml/RunInUnitySimulationWindow.uxml
-
2com.unity.perception/Runtime/GroundTruth/DatasetCapture.cs
-
2com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
-
4com.unity.perception/Runtime/Randomization/Scenarios/FixedLengthScenario.cs
-
59com.unity.perception/Runtime/Randomization/Scenarios/UnitySimulationScenario.cs
-
59com.unity.perception/Runtime/Randomization/Scenarios/USimScenario.cs
-
0/com.unity.perception/Editor/Randomization/Editors/RunInUnitySimulationWindow.cs.meta
-
0/com.unity.perception/Editor/Randomization/Editors/RunInUnitySimulationWindow.cs
-
0/com.unity.perception/Editor/Randomization/Uxml/RunInUnitySimulationWindow.uxml.meta
-
0/com.unity.perception/Editor/Randomization/Uxml/RunInUnitySimulationWindow.uxml
-
0/com.unity.perception/Runtime/Randomization/Scenarios/UnitySimulationScenario.cs.meta
|
|||
using System; |
|||
using Unity.Simulation; |
|||
|
|||
namespace UnityEngine.Experimental.Perception.Randomization.Scenarios |
|||
{ |
|||
/// <summary>
|
|||
/// Defines a scenario that is compatible with the Run in Unity Simulation window
|
|||
/// </summary>
|
|||
/// <typeparam name="T">The type of constants to serialize</typeparam>
|
|||
public abstract class UnitySimulationScenario<T> : Scenario<T> where T : UnitySimulationConstants, new() |
|||
{ |
|||
/// <summary>
|
|||
/// Returns whether the entire scenario has completed
|
|||
/// </summary>
|
|||
public sealed override bool isScenarioComplete => currentIteration >= constants.totalIterations; |
|||
|
|||
/// <summary>
|
|||
/// Progresses the current scenario iteration
|
|||
/// </summary>
|
|||
protected sealed override void IncrementIteration() |
|||
{ |
|||
currentIteration += constants.instanceCount; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Deserializes this scenario's constants from the Unity Simulation AppParams Json file
|
|||
/// </summary>
|
|||
public sealed override void Deserialize() |
|||
{ |
|||
if (Configuration.Instance.IsSimulationRunningInCloud()) |
|||
constants = Configuration.Instance.GetAppParams<T>(); |
|||
else |
|||
base.Deserialize(); |
|||
currentIteration = constants.instanceIndex; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// A class encapsulating the scenario constants fields required for Unity Simulation cloud execution
|
|||
/// </summary>
|
|||
[Serializable] |
|||
public class UnitySimulationConstants |
|||
{ |
|||
/// <summary>
|
|||
/// The total number of iterations to run a scenario for
|
|||
/// </summary>
|
|||
public int totalIterations = 100; |
|||
|
|||
/// <summary>
|
|||
/// The number of Unity Simulation instances assigned to executed this scenario
|
|||
/// </summary>
|
|||
public int instanceCount = 1; |
|||
|
|||
/// <summary>
|
|||
/// The Unity Simulation instance index of the currently executing worker
|
|||
/// </summary>
|
|||
public int instanceIndex; |
|||
} |
|||
} |
|
|||
using System; |
|||
using Unity.Simulation; |
|||
|
|||
namespace UnityEngine.Experimental.Perception.Randomization.Scenarios |
|||
{ |
|||
/// <summary>
|
|||
/// Defines a scenario that is compatible with the Run in USim window
|
|||
/// </summary>
|
|||
/// <typeparam name="T">The type of constants to serialize</typeparam>
|
|||
public abstract class USimScenario<T> : Scenario<T> where T : USimConstants, new() |
|||
{ |
|||
/// <summary>
|
|||
/// Returns whether the entire scenario has completed
|
|||
/// </summary>
|
|||
public sealed override bool isScenarioComplete => currentIteration >= constants.totalIterations; |
|||
|
|||
/// <summary>
|
|||
/// Progresses the current scenario iteration
|
|||
/// </summary>
|
|||
protected sealed override void IncrementIteration() |
|||
{ |
|||
currentIteration += constants.instanceCount; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Deserializes this scenario's constants from the USim AppParams Json file
|
|||
/// </summary>
|
|||
public sealed override void Deserialize() |
|||
{ |
|||
if (Configuration.Instance.IsSimulationRunningInCloud()) |
|||
constants = Configuration.Instance.GetAppParams<T>(); |
|||
else |
|||
base.Deserialize(); |
|||
currentIteration = constants.instanceIndex; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// A class encapsulating the scenario constants fields required for USim cloud execution
|
|||
/// </summary>
|
|||
[Serializable] |
|||
public class USimConstants |
|||
{ |
|||
/// <summary>
|
|||
/// The total number of iterations to run a scenario for
|
|||
/// </summary>
|
|||
public int totalIterations = 100; |
|||
|
|||
/// <summary>
|
|||
/// The number of USim instances assigned to executed this scenario
|
|||
/// </summary>
|
|||
public int instanceCount = 1; |
|||
|
|||
/// <summary>
|
|||
/// The USim instance index of the currently executing worker
|
|||
/// </summary>
|
|||
public int instanceIndex; |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue