Unity 机器学习代理工具包 (ML-Agents) 是一个开源项目,它使游戏和模拟能够作为训练智能代理的环境。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

63 行
2.0 KiB

#if UNITY_2020_1_OR_NEWER
using UnityEngine;
using NUnit.Framework;
using Unity.MLAgents.Extensions.Sensors;
namespace Unity.MLAgents.Extensions.Tests.Sensors
{
public class ArticulationBodyPoseExtractorTests
{
[TearDown]
public void RemoveGameObjects()
{
var objects = GameObject.FindObjectsOfType<GameObject>();
foreach (var o in objects)
{
UnityEngine.Object.DestroyImmediate(o);
}
}
[Test]
public void TestNullRoot()
{
var poseExtractor = new ArticulationBodyPoseExtractor(null);
// These should be no-ops
poseExtractor.UpdateLocalSpacePoses();
poseExtractor.UpdateModelSpacePoses();
Assert.AreEqual(0, poseExtractor.NumPoses);
}
[Test]
public void TestSingleBody()
{
var go = new GameObject();
var rootArticBody = go.AddComponent<ArticulationBody>();
var poseExtractor = new ArticulationBodyPoseExtractor(rootArticBody);
Assert.AreEqual(1, poseExtractor.NumPoses);
}
[Test]
public void TestTwoBodies()
{
// * rootObj
// - rootArticBody
// * leafGameObj
// - leafArticBody
var rootObj = new GameObject();
var rootArticBody = rootObj.AddComponent<ArticulationBody>();
var leafGameObj = new GameObject();
var leafArticBody = leafGameObj.AddComponent<ArticulationBody>();
leafGameObj.transform.SetParent(rootObj.transform);
leafArticBody.jointType = ArticulationJointType.RevoluteJoint;
var poseExtractor = new ArticulationBodyPoseExtractor(rootArticBody);
Assert.AreEqual(2, poseExtractor.NumPoses);
Assert.AreEqual(-1, poseExtractor.GetParentIndex(0));
Assert.AreEqual(0, poseExtractor.GetParentIndex(1));
}
}
}
#endif