浏览代码

Capture scheduling tests pass now

/solo_support
Steve Borkman 3 年前
当前提交
3e9bbc3a
共有 3 个文件被更改,包括 41 次插入10 次删除
  1. 5
      com.unity.perception/Runtime/GroundTruth/DatasetCapture.cs
  2. 7
      com.unity.perception/Runtime/GroundTruth/SimulationState.cs
  3. 39
      com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs

5
com.unity.perception/Runtime/GroundTruth/DatasetCapture.cs


Id = id ?? string.Empty;
}
public override string ToString()
{
return Id;
}
/// <summary>
/// Whether the sensor is currently enabled. When disabled, the DatasetCapture will no longer schedule frames for running captures on this sensor.
/// </summary>

7
com.unity.perception/Runtime/GroundTruth/SimulationState.cs


modality = sensor.modality,
description = sensor.definition,
firstCaptureTime = UnscaledSequenceTime + sensor.firstCaptureFrame * renderingDeltaTime,
captureTriggerMode = CaptureTriggerMode.Scheduled, // TODO fix this
captureTriggerMode = sensor.captureTriggerMode,
renderingDeltaTime = renderingDeltaTime,
framesBetweenCaptures = sensor.framesBetweenCaptures,
manualSensorAffectSimulationTiming = sensor.manualSensorsAffectTiming,

public void SetNextCaptureTimeToNowForSensor(SensorHandle sensorHandle)
{
if (!m_Sensors.ContainsKey(sensorHandle))
{
Debug.LogError($"Tried to set a capture time for an unregistered sensor: {sensorHandle}");
}
var data = m_Sensors[sensorHandle];
data.sequenceTimeOfNextCapture = UnscaledSequenceTime;

// This is just here for debug reasons, this here will always report errors, but they get cleaned up in shutdown
// VerifyNoMorePendingFrames();
Time.captureDeltaTime = 0;
ExecutionState = ExecutionStateType.ShuttingDown;
}
#endif

39
com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs


using System.Text.RegularExpressions;
using NUnit.Framework;
using Unity.Mathematics;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Perception.GroundTruth;
using UnityEngine.Perception.GroundTruth.DataModel;

internal SimulationStateTestHelper()
{
DatasetCapture.Instance.automaticShutdown = false;
m_State = DatasetCapture.Instance.currentSimulation;
var bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance;
m_SequenceTimeOfNextCaptureMethod = m_State.GetType().GetMethod("GetSequenceTimeOfNextCapture", bindingFlags);

DatasetCapture.Instance.ResetSimulation();
}
SensorDefinition CreateSensorDefinition(string id, string modality, string def, int firstFrame, CaptureTriggerMode mode, float deltaTime, int framesBetween)
SensorDefinition CreateSensorDefinition(string id, string modality, string def, int firstFrame, CaptureTriggerMode mode, float deltaTime, int framesBetween, bool manualSensorAffectSimulationTiming = false)
{
return new SensorDefinition(id, modality, def)
{

framesBetweenCaptures = framesBetween
framesBetweenCaptures = framesBetween,
manualSensorsAffectTiming = manualSensorAffectSimulationTiming
};
}

DatasetCapture.Instance.ResetSimulation();
Assert.AreEqual(0, Time.captureDeltaTime);
}
#if false
#if true
[UnityTest]
public IEnumerator ShouldCaptureFlagsAndRenderTimesAreCorrectWithMultipleSensors()
{

//Third sensor is a manually triggered one. All it does in this test is affect delta times.
var simDeltaTime3 = 5;
var sensor3 = DatasetCapture.Instance.RegisterSensor(CreateSensorDefinition("cam3", "", "", 0, CaptureTriggerMode.Manual, simDeltaTime3, 0)); // why is there a true on this one
var sensor3 = DatasetCapture.Instance.RegisterSensor(CreateSensorDefinition("cam3", "", "", 0, CaptureTriggerMode.Manual, simDeltaTime3, 0, true));
(float deltaTime, bool sensor1ShouldCapture, bool sensor2ShouldCapture, bool sensor3ShouldCapture)[] samplesExpected =
{

[TestCase(235, 10, 2350, 2585, 2820, 3055, ExpectedResult = (IEnumerator)null)]
public IEnumerator SequenceTimeOfNextCapture_ReportsCorrectTime_VariedDeltaTimesAndStartFrames(float simulationDeltaTime, int firstCaptureFrame, float firstCaptureTime, float secondCaptureTime, float thirdCaptureTime, float fourthCaptureTime)
{
var sensorHandle = DatasetCapture.Instance.RegisterSensor(CreateSensorDefinition("cam", "", "", firstCaptureFrame, CaptureTriggerMode.Scheduled, simulationDeltaTime, 0));
float[] sequenceTimesExpected =

Assert.AreEqual(sequenceTimesExpected[i], sequenceTimeActual, 0.0001f);
yield return null;
}
// DatasetCapture.Instance.ResetSimulation();
// var dcWatcher = new DatasetCapture.WaitUntilComplete();
// yield return dcWatcher;
#if false
#if true
var sensorHandle = DatasetCapture.Instance.RegisterSensor(CreateSensorDefinition("cam", "", "", 0, CaptureTriggerMode.Manual, 0, 0)); // why is there supposed to be a falise at the end of this
var sensorHandle = DatasetCapture.Instance.RegisterSensor(CreateSensorDefinition("cam", "", "", 0, CaptureTriggerMode.Manual, 0, 0, false));
var framesToCaptureOn = new List<int>();

var elapsed = Time.time - startTime;
Assert.AreEqual(elapsed, sequenceTimeActual, 0.0001f);
}
if (Time.frameCount > 1000)
{
Debug.Log("Pulling the eject handle");
yield break;
}
yield return null;
}

#if false
#if true
var sensorHandle = DatasetCapture.Instance.RegisterSensor(CreateSensorDefinition("cam", "", "", 0, CaptureTriggerMode.Manual, simulationDeltaTime, 0)); // why was there a true here...
var sensorHandle = DatasetCapture.Instance.RegisterSensor(CreateSensorDefinition("cam", "", "", 0, CaptureTriggerMode.Manual, simulationDeltaTime, 0, true));
var framesToCaptureOn = new List<int>();

Assert.AreEqual(sequenceTimesExpected[frameIndex], sequenceTimeActual, 0.0001f);
frameIndex++;
}
if (Time.frameCount > 1000)
{
Debug.Log("Pulling the eject handle");
yield break;
}
yield return null;
}
Assert.AreEqual(frameIndex, framesToCaptureOn.Count, 0.0001f);

正在加载...
取消
保存