Пример #1
0
        private void ImportLinkData(Link link, Joint joint)
        {
            if (link.inertial == null && joint == null)
            {
                isBaseLink = true;
            }

            gameObject.name = link.name;

            if (joint?.origin != null)
            {
                UrdfOrigin.ImportOriginData(transform, joint.origin);
            }

            if (link.inertial != null)
            {
                UrdfInertial.Create(gameObject, link.inertial);

                if (joint != null)
                {
                    UrdfJoint.Create(gameObject, UrdfJoint.GetJointType(joint.type), joint);
                }
            }
            else if (joint != null)
            {
                Debug.LogWarning("No Joint Component will be created in GameObject \"" + gameObject.name + "\" as it has no Rigidbody Component.\n"
                                 + "Please define an Inertial for Link \"" + link.name + "\" in the URDF file to create a Rigidbody Component.\n", gameObject);
            }

            foreach (Joint childJoint in link.joints)
            {
                Link child = childJoint.ChildLink;
                UrdfLink.Create(transform, child, childJoint);
            }
        }
Пример #2
0
        public static void Create()
        {
            GameObject robotGameObject = new GameObject("Robot");

            robotGameObject.AddComponent <UrdfRobot>();

            UrdfPlugins.Create(robotGameObject.transform);

            UrdfLink urdfLink = UrdfLink.Create(robotGameObject.transform);

            urdfLink.name       = "base_link";
            urdfLink.isBaseLink = true;
        }
Пример #3
0
        public static UrdfLink Create(Transform parent, Link link = null, Joint joint = null)
        {
            GameObject linkObject = new GameObject("link");

            linkObject.transform.SetParentAndAlign(parent);
            UrdfLink urdfLink = linkObject.AddComponent <UrdfLink>();

            UrdfVisuals.Create(linkObject.transform, link?.visuals);
            UrdfCollisions.Create(linkObject.transform, link?.collisions);

            if (link != null)
            {
                urdfLink.ImportLinkData(link, joint);
            }
            else
            {
                UrdfInertial.Create(linkObject);
                EditorGUIUtility.PingObject(linkObject);
            }

            return(urdfLink);
        }
Пример #4
0
        public static void Create(string filename)
        {
            Robot robot = new Robot(filename);

            if (!UrdfAssetPathHandler.IsValidAssetPath(robot.filename))
            {
                Debug.LogError("URDF file and ressources must be placed in Assets Folder:\n" + Application.dataPath);
                return;
            }

            GameObject robotGameObject = new GameObject(robot.name);

            robotGameObject.AddComponent <UrdfRobot>();

            UrdfAssetPathHandler.SetPackageRoot(Path.GetDirectoryName(robot.filename));
            UrdfMaterial.InitializeRobotMaterials(robot);
            UrdfPlugins.Create(robotGameObject.transform, robot.plugins);

            UrdfLink.Create(robotGameObject.transform, robot.root);

            GameObjectUtility.SetParentAndAlign(robotGameObject, Selection.activeObject as GameObject);
            Undo.RegisterCreatedObjectUndo(robotGameObject, "Create " + robotGameObject.name);
            Selection.activeObject = robotGameObject;
        }