Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            if (buttonStyle == null)
            {
                buttonStyle = new GUIStyle(EditorStyles.miniButtonRight)
                {
                    fixedWidth = 75
                }
            }
            ;

            urdfRobot = (UrdfRobot)target;

            EditorGUILayout.PropertyField(axisType, new GUIContent("Axis Type"));
            serializedObject.ApplyModifiedProperties();
            UrdfRobotExtensions.CorrectAxis(urdfRobot.gameObject);

            GUILayout.Space(5);
            GUILayout.Label("All Rigidbodies", EditorStyles.boldLabel);
            DisplaySettingsToggle(new GUIContent("Use Gravity", "If disabled, robot is not affected by gravity."), urdfRobot.SetRigidbodiesUseGravity, UrdfRobot.useGravity);
            DisplaySettingsToggle(new GUIContent("Use Inertia from URDF", "If disabled, Unity will generate new inertia tensor values automatically."), urdfRobot.SetUseUrdfInertiaData,
                                  UrdfRobot.useUrdfInertiaData);
            DisplaySettingsToggle(new GUIContent("Default Space"), urdfRobot.ChangeToCorrectedSpace, UrdfRobot.changetoCorrectedSpace);

            GUILayout.Space(5);
            GUILayout.Label("All Colliders", EditorStyles.boldLabel);
            DisplaySettingsToggle(new GUIContent("Convex"), urdfRobot.SetCollidersConvex, UrdfRobot.collidersConvex);

            GUILayout.Space(5);
            GUILayout.Label("All Joints", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Generate Unique Joint Names");
            if (GUILayout.Button("Generate", new GUIStyle(EditorStyles.miniButton)
            {
                fixedWidth = 155
            }))
            {
                urdfRobot.GenerateUniqueJointNames();
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);
            EditorGUILayout.PropertyField(axisType, new GUIContent("Axis Type", "Adjust this if the models that make up your robot are facing the wrong direction."));
            serializedObject.ApplyModifiedProperties();
            UrdfRobotExtensions.CorrectAxis(urdfRobot.gameObject);

            if (urdfRobot.GetComponent <RosSharp.Control.Controller>() == null || urdfRobot.GetComponent <RosSharp.Control.FKRobot>() == null)
            {
                GUILayout.Label("Components", EditorStyles.boldLabel);
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(urdfRobot.GetComponent <RosSharp.Control.Controller>() == null? "Add Controller": "Remove Controller"))
                {
                    urdfRobot.AddController();
                }
                if (urdfRobot.GetComponent <RosSharp.Control.FKRobot>() == null)
                {
                    if (GUILayout.Button("Add Forward Kinematics"))
                    {
                        urdfRobot.gameObject.AddComponent <RosSharp.Control.FKRobot>();
                    }
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(5);
            GUILayout.Label("URDF Files", EditorStyles.boldLabel);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Export robot to URDF"))
            {
                exportRoot = EditorUtility.OpenFolderPanel("Select export directory", exportRoot, "");

                if (exportRoot.Length == 0)
                {
                    return;
                }
                else if (!Directory.Exists(exportRoot))
                {
                    EditorUtility.DisplayDialog("Export Error", "Export root folder must be defined and folder must exist.", "Ok");
                }
                else
                {
                    urdfRobot.ExportRobotToUrdf(exportRoot);
                    SetEditorPrefs();
                }
            }

            GUILayout.Space(5);
            if (GUILayout.Button("Compare URDF Files"))
            {
                CompareURDF window = (CompareURDF)EditorWindow.GetWindow(typeof(CompareURDF));
                window.minSize = new Vector2(500, 200);
                window.GetEditorPrefs();
                window.Show();
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            if (buttonStyle == null)
            {
                buttonStyle = new GUIStyle(EditorStyles.miniButtonRight)
                {
                    fixedWidth = 75
                }
            }
            ;

            urdfRobot = (UrdfRobot)target;

            GUILayout.Space(5);
            GUILayout.Label("All Rigidbodies", EditorStyles.boldLabel);
            DisplaySettingsToggle(new GUIContent("Use Gravity"), urdfRobot.SetRigidbodiesUseGravity);
            DisplaySettingsToggle(new GUIContent("Use Inertia from URDF", "If disabled, Unity will generate new inertia tensor values automatically."),
                                  urdfRobot.SetUseUrdfInertiaData);
            DisplaySettingsToggle(new GUIContent("Default Space"), urdfRobot.ChangeToCorrectedSpace);

            GUILayout.Space(5);
            GUILayout.Label("All Colliders", EditorStyles.boldLabel);
            DisplaySettingsToggle(new GUIContent("Convex"), urdfRobot.SetCollidersConvex);

            GUILayout.Space(5);
            GUILayout.Label("All Joints", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Generate Unique Joint Names");
            if (GUILayout.Button("Generate", new GUIStyle(EditorStyles.miniButton)
            {
                fixedWidth = 155
            }))
            {
                urdfRobot.GenerateUniqueJointNames();
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);
            EditorGUILayout.PropertyField(axisType, new GUIContent("Axis Type"));
            serializedObject.ApplyModifiedProperties();
            UrdfRobotExtensions.CorrectAxis(urdfRobot.gameObject, urdfRobot.choosenAxis);
            GUILayout.Label("Helper Scripts", EditorStyles.boldLabel);
            DisplaySettingsToggle(new GUIContent("Controller Script"), urdfRobot.AddController);
            DisplaySettingsToggle(new GUIContent("Forward Kinematics Script"), urdfRobot.AddFkRobot);

            GUILayout.Space(5);
            if (GUILayout.Button("Export robot to URDF file"))
            {
                // Get existing open window or if none, make a new one:
                UrdfExportEditorWindow window = (UrdfExportEditorWindow)EditorWindow.GetWindow(typeof(UrdfExportEditorWindow));
                window.urdfRobot = urdfRobot;
                window.minSize   = new Vector2(500, 200);
                window.GetEditorPrefs();
                window.Show();
            }

            GUILayout.Space(5);
            if (GUILayout.Button("Compare URDF Files"))
            {
                CompareURDF window = (CompareURDF)EditorWindow.GetWindow(typeof(CompareURDF));
                window.minSize = new Vector2(500, 200);
                window.GetEditorPrefs();
                window.Show();
            }
        }