浏览代码

Merge branch 'randomizers' into tutorial_sample_project

/main
mohsen.k 4 年前
当前提交
15ff95fb
共有 7 个文件被更改,包括 60 次插入13 次删除
  1. 4
      com.unity.perception/Editor/Randomization/Editors/RunInUSimWindow.cs
  2. 11
      com.unity.perception/Runtime/Randomization/Randomizers/SampleRandomizers/Randomizers/SunAngleRandomizer.cs
  3. 3
      com.unity.perception/Runtime/Randomization/Scenarios/Scenario.cs
  4. 15
      com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
  5. 38
      com.unity.perception/Runtime/Randomization/Scenarios/USimScenario.cs
  6. 1
      com.unity.perception/Tests/Runtime/Randomization/RandomizerTests/RandomizerTagTests.cs
  7. 1
      com.unity.perception/Tests/Runtime/Randomization/RandomizerTests/RandomizerTests.cs

4
com.unity.perception/Editor/Randomization/Editors/RunInUSimWindow.cs


namespace UnityEngine.Perception.Randomization.Editor
{
public class RunInUSimWindow : EditorWindow
class RunInUSimWindow : EditorWindow
{
string m_BuildZipPath;
SysParamDefinition m_SysParam;

Button m_RunButton;
[MenuItem("Window/Run in USim")]
public static void ShowWindow()
static void ShowWindow()
{
var window = GetWindow<RunInUSimWindow>();
window.titleContent = new GUIContent("Run In Unity Simulation");

11
com.unity.perception/Runtime/Randomization/Randomizers/SampleRandomizers/Randomizers/SunAngleRandomizer.cs


[AddRandomizerMenu("Perception/Sun Angle Randomizer")]
public class SunAngleRandomizer : Randomizer
{
/// <summary>
/// The hour of the day (0 to 24)
/// </summary>
/// <summary>
/// The time of the year (0 being Jan 1st and 1 being December 31st)
/// </summary>
/// <summary>
/// The earth's latitude (-90 is the south pole, 0 is the equator, and +90 is the north pole)
/// </summary>
public FloatParameter latitude = new FloatParameter { value = new UniformSampler(-90, 90)};
/// <summary>

3
com.unity.perception/Runtime/Randomization/Scenarios/Scenario.cs


/// </summary>
public T constants = new T();
/// <summary>
/// Returns this scenario's non-typed serialized constants
/// </summary>
public override object genericConstants => constants;
/// <summary>

15
com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs


public string serializedConstantsFilePath =>
Application.dataPath + "/StreamingAssets/" + serializedConstantsFileName + ".json";
/// <summary>
/// Returns this scenario's non-typed serialized constants
/// </summary>
public abstract object genericConstants { get; }
/// <summary>

public abstract bool isScenarioComplete { get; }
/// <summary>
/// Progresses the current scenario iteration.
/// Progresses the current scenario iteration
/// </summary>
protected virtual void IncrementIteration()
{

}
// Wait for any final uploads before exiting quitting
if (m_WaitingForFinalUploads)
if (m_WaitingForFinalUploads && quitOnComplete)
Manager.Instance.Shutdown();
if (quitOnComplete)
UnityEditor.EditorApplication.ExitPlaymode();
UnityEditor.EditorApplication.ExitPlaymode();
Application.Quit();
Application.Quit();
#endif
return;
}

{
foreach (var randomizer in activeRandomizers)
randomizer.ScenarioComplete();
Manager.Instance.Shutdown();
DatasetCapture.ResetSimulation();
m_WaitingForFinalUploads = true;
return;

38
com.unity.perception/Runtime/Randomization/Scenarios/USimScenario.cs


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 override bool isScenarioComplete => currentIteration >= constants.totalIterations;
/// <summary>
/// Returns whether the entire scenario has completed
/// </summary>
public sealed override bool isScenarioComplete => currentIteration >= constants.totalIterations;
protected override void OnAwake()
/// <summary>
/// OnAwake is executed directly after this scenario has been registered and initialized
/// </summary>
protected sealed override void OnAwake()
protected override void IncrementIteration()
/// <summary>
/// Progresses the current scenario iteration
/// </summary>
protected sealed override void IncrementIteration()
public override void Deserialize()
/// <summary>
/// Deserializes this scenario's constants from the USim AppParams Json file
/// </summary>
public sealed override void Deserialize()
{
if (string.IsNullOrEmpty(Unity.Simulation.Configuration.Instance.SimulationConfig.app_param_uri))
base.Deserialize();

}
/// <summary>
/// A class encapsulating the scenario constants fields required for USim cloud execution
/// </summary>
/// <summary>
/// The total number of iterations to run a scenario for
/// </summary>
/// <summary>
/// The number of USim instances assigned to executed this scenario
/// </summary>
/// <summary>
/// The USim instance index of the currently executing worker
/// </summary>
public int instanceIndex;
}
}

1
com.unity.perception/Tests/Runtime/Randomization/RandomizerTests/RandomizerTagTests.cs


{
m_TestObject = new GameObject();
m_Scenario = m_TestObject.AddComponent<FixedLengthScenario>();
m_Scenario.quitOnComplete = false;
}
[TearDown]

1
com.unity.perception/Tests/Runtime/Randomization/RandomizerTests/RandomizerTests.cs


public void OneRandomizerInstancePerTypeTest()
{
m_Scenario = m_TestObject.AddComponent<FixedLengthScenario>();
m_Scenario.quitOnComplete = false;
m_Scenario.CreateRandomizer<ExampleTransformRandomizer>();
Assert.Throws<ScenarioException>(() => m_Scenario.CreateRandomizer<ExampleTransformRandomizer>());
}

正在加载...
取消
保存