浏览代码

Adding CustomAnnotationAndMetricExample and adding content to SimulationManager.md

/update-setup-steps
Jon Hogins 5 年前
当前提交
6593e456
共有 7 个文件被更改,包括 97 次插入6 次删除
  1. 29
      TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity
  2. 2
      TestProjects/PerceptionURP/ProjectSettings/QualitySettings.asset
  3. 5
      com.unity.perception/Documentation~/SimulationManager.md
  4. 3
      TestProjects/PerceptionURP/Assets/ExampleScripts.meta
  5. 61
      TestProjects/PerceptionURP/Assets/ExampleScripts/CustomAnnotationAndMetricExample.cs
  6. 3
      TestProjects/PerceptionURP/Assets/ExampleScripts/CustomAnnotationAndMetricExample.cs.meta

29
TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity


m_Script: {fileID: 11500000, guid: 8b33f0bc2b78db642a758f07826d0dd0, type: 3}
m_Name:
m_EditorClassIdentifier:
classes:
labels:
- Crate
--- !u!65 &411238278
BoxCollider:

m_Script: {fileID: 11500000, guid: 8b33f0bc2b78db642a758f07826d0dd0, type: 3}
m_Name:
m_EditorClassIdentifier:
classes:
labels:
- Cube
--- !u!65 &464025706
BoxCollider:

- component: {fileID: 963194230}
- component: {fileID: 963194229}
- component: {fileID: 963194227}
- component: {fileID: 963194231}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera

m_RequiresDepthTextureOption: 2
m_RequiresOpaqueTextureOption: 2
m_CameraType: 0
m_CameraOutput: 0
m_Cameras: []
m_RendererIndex: -1
m_VolumeLayerMask:

m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2

captureRgbImages: 1
produceSegmentationImages: 1
produceObjectCountAnnotations: 1
objectCountId: 51DA3C27-369D-4929-AEA6-D01614635CE2
produceBoundingBoxAnnotations: 1
boundingBoxId: F9F22E05-443F-4602-A422-EBE4EA9B55CB
produceRenderedObjectInfoMetric: 1
renderedObjectInfoId: 5BA92024-B3B7-41A7-9D3F-C03A6A8DDD01
boundingBoxOrigin: 0
--- !u!114 &963194231
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7c51d9f2c5784bb4aee3fdf021966e14, type: 3}
m_Name:
m_EditorClassIdentifier:
light: {fileID: 705507993}
target: {fileID: 1640252278}
--- !u!1 &1640252278
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 8b33f0bc2b78db642a758f07826d0dd0, type: 3}
m_Name:
m_EditorClassIdentifier:
classes:
labels:
- Box
--- !u!65 &1640252280
BoxCollider:

2
TestProjects/PerceptionURP/ProjectSettings/QualitySettings.asset


skinWeights: 2
textureQuality: 0
anisotropicTextures: 1
antiAliasing: 2
antiAliasing: 0
softParticles: 0
softVegetation: 1
realtimeReflectionProbes: 1

5
com.unity.perception/Documentation~/SimulationManager.md


# SimulationManager
The SimulationManager tracks egos, sensors, annotations, and metrics, combining them into a unified [JSON-based dataset](Schema/Synthetic_Dataset_Schema.md) on disk. While sensors are registered, the SimulationManager ensures that frames are deterministic and run at the appropriate simulation times to let each sensor run at its own rate.
`SimulationManager` tracks egos, sensors, annotations, and metrics, combining them into a unified [JSON-based dataset](Schema/Synthetic_Dataset_Schema.md) on disk. It also controls the simulation time elapsed per frame to accommodate the active sensors.
While sensors are registered, `SimulationManager` ensures that frame timing is deterministic and run at the appropriate simulation times to let each sensor run at its own rate.
Using [Time.CaptureDeltaTime](https://docs.unity3d.com/ScriptReference/Time-captureDeltaTime.html), it also decouples wall clock time from simulation time, allowing the simulation to run as fast as possible.
## Custom annotations and metrics

3
TestProjects/PerceptionURP/Assets/ExampleScripts.meta


fileFormatVersion: 2
guid: c9dacfa32295429db4916fd3ba0a3b40
timeCreated: 1591367506

61
TestProjects/PerceptionURP/Assets/ExampleScripts/CustomAnnotationAndMetricExample.cs


using System;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Perception.GroundTruth;
[RequireComponent(typeof(PerceptionCamera))]
public class CustomAnnotationAndMetricExample : MonoBehaviour
{
public GameObject light;
public GameObject target;
MetricDefinition lightPositionMetricDefinition;
AnnotationDefinition targetBoundingBoxAnnotationDefinition;
SensorHandle cameraSensorHandle;
public void Start()
{
//Metrics and annotations are registered up-front and are referenced later when values are reported
lightPositionMetricDefinition = SimulationManager.RegisterMetricDefinition(
"Light position",
"The world-space position of the light",
Guid.Parse("1F6BFF46-F884-4CC5-A878-DB987278FE35"));
targetBoundingBoxAnnotationDefinition = SimulationManager.RegisterAnnotationDefinition(
"Target bounding box",
"The axis-aligned bounding box of the target in the camera's local space",
id: Guid.Parse("C0B4A22C-0420-4D9F-BAFC-954B8F7B35A7"));
}
public void Update()
{
//Report the light's position by manually creating the json array string.
var lightPosition = light.transform.position;
SimulationManager.ReportMetric(lightPositionMetricDefinition,
$@"[{{ ""x"": {lightPosition.x}, ""y"": {lightPosition.y}, ""z"": {lightPosition.z} }}]");
//compute the location of the object in the camera's local space
var targetCameraLocalPosition = transform.worldToLocalMatrix * target.transform.position;
//Report the annotation on the camera SensorHandle exposed by the PerceptionCamera
GetComponent<PerceptionCamera>().SensorHandle.ReportAnnotationValues(targetBoundingBoxAnnotationDefinition,new[] { targetCameraLocalPosition });
}
}
//
// {
// "id": "71265896-2a46-405a-a3d9-e587cdfac631",
// "annotation_definition": "c0b4a22c-0420-4d9f-bafc-954b8f7b35a7",
// "values": [
// {
// "Center": {
// "x": -85.386672973632813,
// "y": 84.000732421875,
// "z": 112.38008880615234
// },
// "Extents": {
// "x": 0.64206844568252563,
// "y": 0.71592754125595093,
// "z": 0.66213905811309814
// }
// }
// ]
// },

3
TestProjects/PerceptionURP/Assets/ExampleScripts/CustomAnnotationAndMetricExample.cs.meta


fileFormatVersion: 2
guid: 7c51d9f2c5784bb4aee3fdf021966e14
timeCreated: 1591367532
正在加载...
取消
保存