浏览代码

reseting data capture sequence for every scenario iteration

/usim-randomization
Steven Leal 4 年前
当前提交
56db83ee
共有 3 个文件被更改,包括 43 次插入7 次删除
  1. 2
      com.unity.perception/Documentation~/Randomization/Tutorial.md
  2. 11
      com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
  3. 37
      com.unity.perception/Tests/Runtime/Randomization/ScenarioTests.cs

2
com.unity.perception/Documentation~/Randomization/Tutorial.md


public int totalIterations = 1000;
}
public override bool isIterationComplete => framesSinceIterationSetup >= 1;
public override bool isIterationComplete => currentIterationFrame >= 1;
public override bool isScenarioComplete => currentIteration >= constants.totalIterations;
public ColorHsvaParameter backgroundColorParameter;

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


using System;
using System.Collections;
using UnityEngine;
using UnityEngine.Perception.GroundTruth;
using UnityEngine.Perception.Randomization.Configuration;
using UnityEngine.Perception.Randomization.Parameters;

IEnumerator UpdateLoop()
{
// TODO: remove this yield when the perception camera no longer skips the first frame of the simulation
yield return null;
// DatasetCapture.StartNewSequence();
foreach (var config in ParameterConfiguration.configurations)
config.ApplyParameters(currentIteration, ParameterApplicationFrequency.OnIterationSetup);
OnIterationSetup();

currentIteration++;
currentIterationFrame = 0;
}
// Disable perception cameras
foreach (var perceptionCamera in FindObjectsOfType<PerceptionCamera>())
perceptionCamera.enabled = false;
QuitApplication();
}

37
com.unity.perception/Tests/Runtime/Randomization/ScenarioTests.cs


using System.IO;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.Perception.GroundTruth;
using UnityEngine.Perception.Randomization.Configuration;
using UnityEngine.Perception.Randomization.Parameters;
using UnityEngine.Perception.Randomization.Samplers;

Object.DestroyImmediate(m_TestObject);
}
void CreateNewScenario()
IEnumerator CreateNewScenario()
yield return null;
CreateNewScenario();
yield return CreateNewScenario();
m_Scenario.serializedConstantsFileName = "perception_serialization_test";
var constants = new FixedFrameLengthScenario.Constants

[UnityTest]
public IEnumerator MultipleFrameIterationTest()
{
CreateNewScenario();
yield return CreateNewScenario();
const int testIterationFrameCount = 5;
m_Scenario.constants.framesPerIteration = testIterationFrameCount;

[UnityTest]
public IEnumerator ScenarioCompletionTest()
{
CreateNewScenario();
yield return CreateNewScenario();
const int testIterationTotal = 5;
m_Scenario.constants.framesPerIteration = 1;
m_Scenario.constants.totalIterations = testIterationTotal;

[UnityTest]
public IEnumerator AppliesParametersEveryFrame()
{
CreateNewScenario();
yield return CreateNewScenario();
m_Scenario.constants.framesPerIteration = 5;
m_Scenario.constants.totalIterations = 1;

[UnityTest]
public IEnumerator AppliesParametersEveryIteration()
{
CreateNewScenario();
yield return CreateNewScenario();
m_Scenario.constants.framesPerIteration = 5;
m_Scenario.constants.totalIterations = 1;

// ReSharper disable once Unity.InefficientPropertyAccess
Assert.AreEqual(initialPosition, transform.position);
}
//
// [UnityTest]
// public IEnumerator StartNewDatasetSequenceEveryIteration()
// {
// yield return CreateNewScenario();
// m_Scenario.constants.framesPerIteration = 2;
// m_Scenario.constants.totalIterations = 2;
//
// var perceptionCamera = m_TestObject.AddComponent<PerceptionCamera>();
// perceptionCamera.startTime = 0;
//
// // Skip first frame
// yield return new WaitForEndOfFrame();
// Assert.AreEqual(DatasetCapture.SimulationState.SequenceTime, 0);
//
// // Second frame, first iteration
// yield return new WaitForEndOfFrame();
// Assert.AreEqual(DatasetCapture.SimulationState.SequenceTime, perceptionCamera.period);
//
// // Third frame, second iteration, SequenceTime has been reset
// yield return new WaitForEndOfFrame();
// Assert.AreEqual(DatasetCapture.SimulationState.SequenceTime, 0);
// }
}
}
正在加载...
取消
保存