浏览代码

Supporting the 'step' button in the editor (#294)

* Supporting the 'step' button in the editor.

* Update CHANGELOG.md

* Adding informational log message when frame step is used.
/0.8.0.preview.4_staging
Aryan Mann 3 年前
当前提交
208023a9
共有 4 个文件被更改,包括 33 次插入4 次删除
  1. 2
      com.unity.perception/CHANGELOG.md
  2. 5
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
  3. 14
      com.unity.perception/Runtime/GroundTruth/SimulationState.cs
  4. 16
      com.unity.perception/Tests/Editor/DatasetCaptureEditorTests.cs

2
com.unity.perception/CHANGELOG.md


### Known Issues
### Added
Added support for 'step' button in editor.
### Changed

### Fixed
Fixed keypoint labeling bug when visualizations are disabled.
## [0.8.0-preview.3] - 2021-03-24
### Changed

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


// Ignore the subsequent calls.
if (lastFrameCalledThisCallback == Time.frameCount)
return false;
#if UNITY_EDITOR
if (UnityEditor.EditorApplication.isPaused)
return false;
#endif
return true;
}

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


{
var sensorData = m_Sensors[activeSensor];
#if UNITY_EDITOR
if (UnityEditor.EditorApplication.isPaused)
{
//When the user clicks the 'step' button in the editor, frames will always progress at .02 seconds per step.
//In this case, just run all sensors each frame to allow for debugging
Debug.Log($"Frame step forced all sensors to synchronize, changing frame timings.");
sensorData.sequenceTimeOfNextRender = UnscaledSequenceTime;
sensorData.sequenceTimeOfNextCapture = UnscaledSequenceTime;
}
#endif
if (Mathf.Abs(sensorData.sequenceTimeOfNextRender - UnscaledSequenceTime) < k_SimulationTimingAccuracy)
{
//means this frame fulfills this sensor's simulation time requirements, we can move target to next frame.

sensorData.sequenceTimeOfNextCapture += sensorData.renderingDeltaTime * (sensorData.framesBetweenCaptures + 1);
Debug.Assert(sensorData.sequenceTimeOfNextCapture > UnscaledSequenceTime,
$"Next scheduled capture should be after {UnscaledSequenceTime} but is {sensorData.sequenceTimeOfNextCapture}");
while (sensorData.sequenceTimeOfNextCapture <= UnscaledSequenceTime)
sensorData.sequenceTimeOfNextCapture += sensorData.renderingDeltaTime * (sensorData.framesBetweenCaptures + 1);
}
else if (sensorData.captureTriggerMode.Equals(CaptureTriggerMode.Manual))
{

16
com.unity.perception/Tests/Editor/DatasetCaptureEditorTests.cs


using System.Collections;
using System.IO;
using NUnit.Framework;
using UnityEditor;
using UnityEngine;
using UnityEngine.Perception.GroundTruth;
using UnityEngine.TestTools;

expectedDatasetPath = DatasetCapture.OutputDirectory;
yield return new ExitPlayMode();
FileAssert.Exists(Path.Combine(expectedDatasetPath, "sensors.json"));
}
[UnityTest]
public IEnumerator StepFunction_OverridesSimulationDeltaTime_AndRunsSensors()
{
yield return new EnterPlayMode();
DatasetCapture.ResetSimulation();
var ego = DatasetCapture.RegisterEgo("ego");
var sensor = DatasetCapture.RegisterSensor(ego, "camera", "", 0, CaptureTriggerMode.Scheduled, 2f, 0);
yield return null;
var timeBeforeStep = Time.time;
EditorApplication.isPaused = true;
EditorApplication.Step();
Assert.True(Time.time - timeBeforeStep < .3f);
Assert.True(sensor.ShouldCaptureThisFrame);
yield return new ExitPlayMode();
}
}
}
正在加载...
取消
保存