浏览代码

Sync stateful sampler reset with categorical parameters

/usim-randomization
Steven Leal 4 年前
当前提交
8a38275d
共有 3 个文件被更改,包括 14 次插入10 次删除
  1. 15
      com.unity.perception/Editor/Randomization/ParameterElement.cs
  2. 3
      com.unity.perception/Runtime/Randomization/Configuration/ParameterConfiguration.cs
  3. 6
      com.unity.perception/Runtime/Randomization/Parameters/CategoricalParameter.cs

15
com.unity.perception/Editor/Randomization/ParameterElement.cs


m_TargetContainer = this.Q<VisualElement>("target-container");
ToggleTargetContainer();
m_TargetPropertyMenu = this.Q<ToolbarMenu>("property-select-menu");
targetField.BindProperty(m_SerializedProperty.FindPropertyRelative("target.gameObject"));
targetField.RegisterCallback<ChangeEvent<Object>>((evt) =>
var targetObjectProperty = m_SerializedProperty.FindPropertyRelative("target.gameObject");
targetField.BindProperty(targetObjectProperty);
targetField.RegisterCallback<ChangeEvent<Object>>(evt =>
if (evt.newValue == targetObjectProperty.objectReferenceValue)
return;
parameter.target.gameObject = (GameObject)evt.newValue;
targetObjectProperty.objectReferenceValue = (GameObject)evt.newValue;
m_SerializedProperty.serializedObject.ApplyModifiedProperties();
ToggleTargetContainer();
FillPropertySelectMenu();
});

{
m_TargetPropertyMenu.menu.AppendAction(
TargetPropertyDisplayText(option),
a => { SetTarget(option); },
a => DropdownMenuAction.Status.Normal);
a => { SetTarget(option); });
}
}

3
com.unity.perception/Runtime/Randomization/Configuration/ParameterConfiguration.cs


public void ResetParameterStates(int scenarioIteration)
{
foreach (var parameter in parameters)
foreach (var sampler in parameter.samplers)
sampler.ResetState(scenarioIteration);
parameter.ResetState(scenarioIteration);
}
/// <summary>

6
com.unity.perception/Runtime/Randomization/Parameters/CategoricalParameter.cs


using System;
using System.Collections.Generic;
using Unity.Assertions;
using UnityEngine.Perception.Randomization.Samplers;
namespace UnityEngine.Perception.Randomization.Parameters

public abstract class CategoricalParameter<T> : CategoricalParameterBase
{
[SerializeField] internal bool uniform;
[SerializeField] UniformSampler m_Sampler = new UniformSampler(0f, 1f);
[SerializeReference] ISampler m_Sampler = new UniformSampler(0f, 1f);
public override ISampler[] samplers => new ISampler[] { m_Sampler };
public override ISampler[] samplers => new [] { m_Sampler };
public sealed override Type OutputType => typeof(T);

if (probabilities.Count != m_Options.Count)
throw new ParameterValidationException(
"Number of options must be equal to the number of probabilities");
NormalizeProbabilities();
}
}

正在加载...
取消
保存