예제 #1
0
        public void ExportGeometryData_MeshUnityDecomposer_DefaultGeometry()
        {
            // Force runtime mode to set testing package root
            RuntimeUrdf.runtimeModeEnabled = true;
            UrdfAssetPathHandler.SetPackageRoot("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/");
            RuntimeUrdf.runtimeModeEnabled     = false;
            UrdfRobotExtensions.importsettings = ImportSettings.DefaultSettings();
            UrdfRobotExtensions.importsettings.convexMethod = ImportSettings.convexDecomposer.unity;

            var    parent       = new GameObject("Parent").transform;
            string path         = "package://meshes/cube.stl";
            var    meshGeometry = new Geometry(mesh: new Mesh(path, new double[] { 1, 1, 1 }));

            UrdfCollisionExtensions.Create(parent, new Collision(meshGeometry));

            UrdfExportPathHandler.SetExportPath("Assets");
            var t      = parent.GetComponentInChildren <UrdfCollision>().transform.GetChild(0);
            var export = UrdfGeometry.ExportGeometryData(GeometryTypes.Mesh, t);

            Assert.IsNotNull(export);

            Object.DestroyImmediate(parent.gameObject);
            List <string> outFailedPaths = new List <string>();

            AssetDatabase.DeleteAssets(new string[] { "Assets/meshes" }, outFailedPaths);
        }
예제 #2
0
        public void Create_CylinderMesh_AssetCreated()
        {
            // Force runtime mode to set testing package root
            RuntimeUrdf.runtimeModeEnabled = true;
            UrdfAssetPathHandler.SetPackageRoot("Assets/Tests/Runtime/GeometryTests");
            RuntimeUrdf.runtimeModeEnabled = false;
            var parent = new GameObject("Parent").transform;

            UrdfGeometryCollision.Create(parent, GeometryTypes.Cylinder);

            // Verify Cylinder created in Hierarchy
            var createdCylinder = parent.Find("Cylinder").gameObject;

            Assert.IsTrue(createdCylinder.activeInHierarchy);
            Assert.IsNotNull(createdCylinder.GetComponent <MeshCollider>());

            // Check for standard values on collider
            Assert.AreEqual(1864, createdCylinder.GetComponent <MeshCollider>().sharedMesh.vertexCount);
            Assert.IsTrue(Vector3.Distance(Vector3.zero, createdCylinder.GetComponent <MeshCollider>().sharedMesh.bounds.center) < centerDelta);
            Assert.IsTrue(Vector3.Distance(new Vector3(0.5f, 1f, 0.5f), createdCylinder.GetComponent <MeshCollider>().sharedMesh.bounds.extents) < scaleDelta);
            // Verify Cylinder created in Assets
            Assert.IsNotNull(RuntimeUrdf.AssetDatabase_FindAssets("Cylinder t:mesh", new string[] { "Assets/Tests/Runtime/GeometryTests" }));

            AssetDatabase.DeleteAsset("Assets/Tests/Runtime/GeometryTests/Cylinder.asset");
            Object.DestroyImmediate(parent.gameObject);
        }
예제 #3
0
        public void Create_FromStlVhacdRuntime_CubeMesh()
        {
            // Force runtime mode to set testing package root
            RuntimeUrdf.runtimeModeEnabled = true;
            UrdfAssetPathHandler.SetPackageRoot("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/");
            UrdfRobotExtensions.importsettings = ImportSettings.DefaultSettings();

            var    parent       = new GameObject("Parent").transform;
            string path         = "package://meshes/cube.stl";
            var    meshGeometry = new Geometry(mesh: new Mesh(path, new double[] { 1, 1, 1 }));

            UrdfCollisionExtensions.Create(parent, new Collision(meshGeometry));

            // Verify geometry created in Hierarchy
            var urdfCollision = parent.GetComponentInChildren <UrdfCollision>().transform;
            var mesh          = urdfCollision.Find("cube/cube_0").gameObject;

            Assert.IsTrue(mesh.activeInHierarchy);
            Assert.IsNotNull(mesh.GetComponent <MeshCollider>());
            Assert.AreEqual(8, mesh.GetComponent <MeshCollider>().sharedMesh.vertexCount);
            Assert.IsTrue(Vector3.Distance(Vector3.one * 15f, mesh.GetComponent <MeshCollider>().sharedMesh.bounds.extents) < scaleDelta);

            // Verify geometry created in Assets
            Assert.IsNotNull(AssetDatabase.FindAssets("cube t:mesh", new string[] { "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/meshes" }));

            AssetDatabase.DeleteAsset("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/meshes/cube_1.asset");
            Object.DestroyImmediate(parent.gameObject);
        }
 public void GetSetPackageRoot_RuntimeModeEnabled_Success()
 {
     // Force runtime mode to set testing package root
     RuntimeUrdf.runtimeModeEnabled = true;
     UrdfAssetPathHandler.SetPackageRoot(assetRoot);       // Set oldPackagePath
     UrdfAssetPathHandler.SetPackageRoot(assetRoot, true); // Run correctPackageRoot
     Assert.AreEqual(assetRoot, UrdfAssetPathHandler.GetPackageRoot());
 }
        public void GetRelativeAssetPathFromUrdfPath_CubeUrdf_Success()
        {
            string urdfRoot = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube";

            // Force runtime mode to set testing package root
            RuntimeUrdf.runtimeModeEnabled = true;
            UrdfAssetPathHandler.SetPackageRoot(urdfRoot);
            RuntimeUrdf.runtimeModeEnabled = false;

            Assert.AreEqual($"{urdfRoot}/meshes/cube.prefab", UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath("package://meshes/cube.stl"));
            Assert.AreEqual($"{urdfRoot}/meshes/cube.prefab", UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath("../meshes/cube.stl"));
        }
예제 #6
0
    public void Synchronize(Robot robot, GameObject rootObject, string assetRoot)
    {
        GameObject robotGameObject = rootObject;

        robotGameObject.AddComponentIfNotExists <UrdfRobot>();

        UrdfAssetPathHandler.SetPackageRoot(assetRoot);
        UrdfMaterial.InitializeRobotMaterials(robot);
        UrdfPlugins.Synchronize(robotGameObject.transform, robot.plugins);

        UrdfLinkExtensions.Synchronize(robotGameObject.transform, robot.root);
    }
        public void GetMaterialAssetPath_AssetAndPackage_Success()
        {
            // Force runtime mode to set testing package root
            RuntimeUrdf.runtimeModeEnabled = true;
            UrdfAssetPathHandler.SetPackageRoot(assetRoot);
            RuntimeUrdf.runtimeModeEnabled = false;
            Assert.AreEqual($"{assetRoot}/Materials/TestMaterial.mat", UrdfAssetPathHandler.GetMaterialAssetPath("TestMaterial"));


            // Force runtime mode to set testing package root
            RuntimeUrdf.runtimeModeEnabled = true;
            UrdfAssetPathHandler.SetPackageRoot(packageRoot);
            RuntimeUrdf.runtimeModeEnabled = false;
            Assert.AreEqual($"{packageRoot}/Materials/TestMaterial.mat", UrdfAssetPathHandler.GetMaterialAssetPath("TestMaterial"));
        }