Пример #1
0
    private void OnGUI()
    {
        // styles
        var titleLabelStyle = new GUIStyle(GUI.skin.label)
        {
            alignment = TextAnchor.MiddleCenter, fontSize = 14
        };
        var subtitleLabelStyle = new GUIStyle(GUI.skin.label)
        {
            alignment = TextAnchor.MiddleCenter, fontSize = 10
        };

        GUILayout.Space(10);
        EditorGUILayout.LabelField("HD Map Import", titleLabelStyle, GUILayout.ExpandWidth(true));
        GUILayout.Space(5);
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        GUILayout.Space(10);

        EditorGUILayout.HelpBox("Settings", UnityEditor.MessageType.Info);
        var selectedNew = EditorGUILayout.Popup("Import Format", Selected, importFormats);

        GUILayout.Space(10);


        if (Selected != selectedNew)
        {
            FileName = "";
            Selected = selectedNew;
        }

        IsMeshNeeded = GUILayout.Toggle(IsMeshNeeded, " Create Signal/sign Mesh?");
        if (importFormats[Selected] == "Apollo 5 HD Map")
        {
            DownSampleDistanceThreshold = EditorGUILayout.FloatField(
                new GUIContent("Distance Threshold", "distance threshold to down sample imported points"),
                DownSampleDistanceThreshold);
            DownSampleDeltaThreshold = EditorGUILayout.FloatField(
                new GUIContent("Delta Threshold", "delta threshold to down sample imported turning lines"),
                DownSampleDeltaThreshold);
            SelectFile(importFormats[Selected], "bin");
        }
        else if (importFormats[Selected] == "Lanelet2 Map")
        {
            SelectFile(importFormats[Selected], "osm");
        }
        else if (importFormats[Selected] == "OpenDRIVE Map")
        {
            IsConnectLanes = GUILayout.Toggle(IsConnectLanes, " Connect Lanes based on Links?");
            DownSampleDistanceThreshold = EditorGUILayout.FloatField(
                new GUIContent("Distance Threshold", "distance threshold to down sample imported points"),
                DownSampleDistanceThreshold);
            DownSampleDeltaThreshold = EditorGUILayout.FloatField(
                new GUIContent("Delta Threshold", "delta threshold to down sample imported turning lines"),
                DownSampleDeltaThreshold);
            SelectFile(importFormats[Selected], "xodr");
        }

        if (GUILayout.Button(new GUIContent("Import", $"Import {importFormats[Selected]}")))
        {
            if (string.IsNullOrEmpty(FileName))
            {
                EditorUtility.DisplayDialog("Error", "Please specify input file/folder name!", "OK");
                return;
            }

            if (importFormats[Selected] == "Apollo 5 HD Map")
            {
                ApolloMapImporter ApolloMapImporter = new ApolloMapImporter(
                    DownSampleDistanceThreshold, DownSampleDeltaThreshold, IsMeshNeeded);
                ApolloMapImporter.Import(FileName);
            }
            else if (importFormats[Selected] == "Lanelet2 Map")
            {
                Lanelet2MapImporter laneLet2MapImporter = new Lanelet2MapImporter(IsMeshNeeded);
                laneLet2MapImporter.Import(FileName);
            }

            if (importFormats[Selected] == "OpenDRIVE Map")
            {
                OpenDriveMapImporter openDriveMapImporter = new OpenDriveMapImporter(
                    DownSampleDistanceThreshold, DownSampleDeltaThreshold,
                    IsMeshNeeded, IsConnectLanes);
                openDriveMapImporter.Import(FileName);
            }
        }
    }
Пример #2
0
        public void ExportImport()
        {
            var environments = Path.Combine(Application.dataPath, "External", "Environments");
            var temp         = Path.Combine(Application.dataPath, "..", "Temp");

            LogAssert.ignoreFailingMessages = true;

            try
            {
                foreach (var path in Directory.EnumerateDirectories(environments))
                {
                    var map = Path.GetFileName(path);

                    if (map.EndsWith("@tmp"))
                    {
                        // skip dummy folders Jenkins creates
                        continue;
                    }

                    if (File.Exists(Path.Combine(path, ".skiptest")))
                    {
                        Debug.LogWarning($"Skipping {map}");
                        continue;
                    }

                    Debug.LogWarning($"****** Testing {map}");

                    var scene = EditorSceneManager.OpenScene(Path.Combine(environments, map, $"{map}.unity"));

                    // export

                    var autoware = new AutowareMapTool();
                    autoware.Export(Path.Combine(temp, $"{map}_autoware"));

                    var apollo3 = new ApolloMapTool(ApolloMapTool.ApolloVersion.Apollo_3_0);
                    apollo3.Export(Path.Combine(temp, $"{map}_apollo3"));

                    Assert.IsFalse(scene.isDirty);

                    var apollo5 = new ApolloMapTool(ApolloMapTool.ApolloVersion.Apollo_5_0);
                    apollo5.Export(Path.Combine(temp, $"{map}_apollo5"));

                    Assert.IsFalse(scene.isDirty);

                    var opendrive = new OpenDriveMapExporter();
                    opendrive.Export(Path.Combine(temp, $"{map}_opendrive"));

                    Assert.IsFalse(scene.isDirty);

                    var lanelet = new Lanelet2MapExporter();
                    lanelet.Export(Path.Combine(temp, $"{map}_lanelet2"));

                    Assert.IsFalse(scene.isDirty);

                    // import

                    EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
                    var apolloImport = new ApolloMapImporter(10f, 0.5f, true);
                    apolloImport.Import(Path.Combine(temp, $"{map}_apollo5"));

                    EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
                    var opendriveImport = new OpenDriveMapImporter(10f, 0.5f, true);
                    opendriveImport.Import(Path.Combine(temp, $"{map}_opendrive"));

                    EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
                    var laneletImport = new Lanelet2MapImporter(true);
                    laneletImport.Import(Path.Combine(temp, $"{map}_lanelet2"));
                }
            }
            finally
            {
                EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
                LogAssert.ignoreFailingMessages = false;
            }
        }