浏览代码

app-params now deserialize from the correct location in usim

/main
Steven Leal 4 年前
当前提交
a44b733e
共有 5 个文件被更改,包括 35 次插入44 次删除
  1. 25
      com.unity.perception/Editor/Randomization/Editors/RandomizerTagEditor.cs
  2. 1
      com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs
  3. 19
      com.unity.perception/Runtime/Randomization/Scenarios/Scenario.cs
  4. 20
      com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
  5. 14
      com.unity.perception/Runtime/Randomization/Scenarios/UnitySimulationScenario.cs

25
com.unity.perception/Editor/Randomization/Editors/RandomizerTagEditor.cs


using UnityEditor;
using UnityEditor.Perception.Randomization;
using UnityEditor.UIElements;
using UnityEngine.Perception.Randomization.Randomizers;
using UnityEngine.UIElements;

[CustomEditor(typeof(RandomizerTag), true)]
public class RandomizerTagEditor : UnityEditor.Editor
{
public override VisualElement CreateInspectorGUI()
{
var rootElement = new VisualElement();
CreatePropertyFields(rootElement);
return rootElement;
}
void CreatePropertyFields(VisualElement rootElement)
{
var iterator = serializedObject.GetIterator();
iterator.NextVisible(true);
do
{
if (iterator.name == "m_Script")
continue;
var propertyField = new PropertyField(iterator.Copy());
propertyField.Bind(serializedObject);
rootElement.Add(propertyField);
} while (iterator.NextVisible(false));
}
}
class RandomizerTagEditor : ParameterUIElementsEditor { }
}

1
com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs


return VisualizationHelper.ConvertToScreenSpace(cam, worldPoint);
}
/// <inheritdoc/>
protected override void OnVisualize()
{
if (m_ToReport == null) return;

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


/// <inheritdoc/>
public override void DeserializeFromFile(string configFilePath)
{
if (string.IsNullOrEmpty(configFilePath))
throw new ArgumentNullException();
if (!File.Exists(configFilePath))
throw new FileNotFoundException($"A scenario configuration file does not exist at path {configFilePath}");
if (string.IsNullOrEmpty(configFilePath) || !File.Exists(configFilePath))
Debug.Log($"No configuration file found at {defaultConfigFilePath}");
else
{
Debug.Log($"Deserialized scenario configuration from <a href=\"file:///${configFilePath}\">{configFilePath}</a>. " +
"Using undo in the editor will revert these changes to your scenario.");
Debug.Log($"Deserialized scenario configuration from <a href=\"file:///${configFilePath}\">{configFilePath}</a>. " +
"Using undo in the editor will revert these changes to your scenario.");
Debug.Log($"Deserialized scenario configuration from <a href=\"file:///${configFilePath}\">{configFilePath}</a>");
Debug.Log($"Deserialized scenario configuration from <a href=\"file:///${configFilePath}\">{configFilePath}</a>");
var jsonText = File.ReadAllText(configFilePath);
DeserializeFromJson(jsonText);
var jsonText = File.ReadAllText(configFilePath);
DeserializeFromJson(jsonText);
}
}
/// <inheritdoc/>

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


/// <summary>
/// Returns the absolute file path of the JSON serialized configuration
/// </summary>
public string defaultConfigFilePath =>
public virtual string defaultConfigFilePath =>
Application.dataPath + "/StreamingAssets/" + configFileName + ".json";
/// <summary>

}
/// <summary>
/// Resets SamplerState.randomState with a new seed value generated by hashing this Scenario's randomSeed
/// with its currentIteration
/// </summary>
protected virtual void ResetRandomStateOnIteration()
{
SamplerState.randomState = SamplerUtility.IterateSeed((uint)currentIteration, genericConstants.randomSeed);
}
/// <summary>
/// This method executed directly after this scenario has been registered and initialized
/// </summary>
protected virtual void OnAwake() { }

Guid.Parse("14adb394-46c0-47e8-a3f0-99e754483b76"));
DatasetCapture.ReportMetric(randomSeedMetricDefinition, new[] { genericConstants.randomSeed });
#if !UNITY_EDITOR
if (File.Exists(defaultConfigFilePath))
DeserializeFromFile();
else
Debug.Log($"No configuration file found at {defaultConfigFilePath}. " +
"Proceeding with built in scenario constants and randomizer settings.");
DeserializeFromFile();
#endif
}

if (currentIterationFrame == 0)
{
DatasetCapture.StartNewSequence();
SamplerState.randomState = SamplerUtility.IterateSeed((uint)currentIteration, genericConstants.randomSeed);
ResetRandomStateOnIteration();
DatasetCapture.ReportMetric(m_IterationMetricDefinition, new[]
{
new IterationMetricData()

14
com.unity.perception/Runtime/Randomization/Scenarios/UnitySimulationScenario.cs


using System;
using System.IO;
using UnityEngine.Perception.Randomization.Samplers;
namespace UnityEngine.Perception.Randomization.Scenarios
{

public sealed override bool isScenarioComplete => currentIteration >= constants.totalIterations;
/// <inheritdoc/>
public override string defaultConfigFilePath =>
Configuration.Instance.IsSimulationRunningInCloud()
? new Uri(Configuration.Instance.SimulationConfig.app_param_uri).LocalPath
: base.defaultConfigFilePath;
/// <inheritdoc/>
protected sealed override void IncrementIteration()
{
currentIteration += constants.instanceCount;

public sealed override void DeserializeFromFile(string configFilePath)
{
base.DeserializeFromFile(Configuration.Instance.IsSimulationRunningInCloud()
? new Uri(Configuration.Instance.SimulationConfig.app_param_uri).LocalPath
: configFilePath);
currentIteration = constants.instanceIndex;
base.DeserializeFromFile(configFilePath);
currentIteration = constants.instanceIndex * constants.instanceCount;
}
}
}
正在加载...
取消
保存