コード例 #1
0
        private static void ImportLinkData(this UrdfLink urdfLink, Link link, Joint joint)
        {
            if (link.inertial == null && joint == null)
            {
                urdfLink.IsBaseLink = true;
            }
            urdfLink.gameObject.name = link.name;
            if (joint?.origin != null)
            {
                UrdfOrigin.ImportOriginData(urdfLink.transform, joint.origin);
            }

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

                if (joint != null)
                {
                    UrdfJoint.Create(urdfLink.gameObject, UrdfJoint.GetJointType(joint.type), joint);
                }
            }
            else if (joint != null)
            {
                UrdfJoint.Create(urdfLink.gameObject, UrdfJoint.GetJointType(joint.type), joint);
            }

            foreach (Joint childJoint in link.joints)
            {
                Link child = childJoint.ChildLink;
                UrdfLinkExtensions.Create(urdfLink.transform, child, childJoint);
            }
        }
コード例 #2
0
        private static void ImportLinkData(this UrdfLink urdfLink, Link link, Joint joint)
        {
            if (link.inertial == null && joint == null)
            {
                urdfLink.IsBaseLink = true;
            }

            urdfLink.gameObject.name = link.name;

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

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

                if (joint != null)
                {
                    UrdfJoint.Create(urdfLink.gameObject, UrdfJoint.GetJointType(joint.type), joint);
                }
            }
            else if (joint != null)
            {
                Debug.LogWarning("No Joint Component will be created in GameObject \"" + urdfLink.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", urdfLink.gameObject);
            }

            foreach (Joint childJoint in link.joints)
            {
                Link child = childJoint.ChildLink;
                UrdfLinkExtensions.Create(urdfLink.transform, child, childJoint);
            }
        }
コード例 #3
0
        public static void Create()
        {
            GameObject robotGameObject = new GameObject("Robot");

            robotGameObject.AddComponent <UrdfRobot>();

            UrdfPlugins.Create(robotGameObject.transform);

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

            urdfLink.name       = "base_link";
            urdfLink.IsBaseLink = true;
        }
コード例 #4
0
        public static Link ExportLinkData(this UrdfLink urdfLink)
        {
            if (urdfLink.transform.localScale != Vector3.one)
            {
                Debug.LogWarning("Only visuals should be scaled. Scale on link \"" + urdfLink.gameObject.name + "\" cannot be saved to the URDF file.", urdfLink.gameObject);
            }
            UrdfInertial urdfInertial = urdfLink.gameObject.GetComponent <UrdfInertial>();
            Link         link         = new Link(urdfLink.gameObject.name)
            {
                visuals    = urdfLink.GetComponentInChildren <UrdfVisuals>().ExportVisualsData(),
                collisions = urdfLink.GetComponentInChildren <UrdfCollisions>().ExportCollisionsData(),
                inertial   = urdfInertial == null ? null : urdfInertial.ExportInertialData()
            };

            return(link);
        }
コード例 #5
0
        public static void Create()
        {
            CreateTag();
            GameObject robotGameObject = new GameObject("Robot");

            robotGameObject.tag = tagName;
            robotGameObject.AddComponent <UrdfRobot>();
            robotGameObject.AddComponent <RosSharp.Control.Controller>();

            UrdfPlugins.Create(robotGameObject.transform);

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

            urdfLink.name       = "base_link";
            urdfLink.IsBaseLink = true;
        }
コード例 #6
0
ファイル: UrdfLinkEditor.cs プロジェクト: Kenjiro56/ROS-GUI-1
        public override void OnInspectorGUI()
        {
            GUILayout.Space(5);
            urdfLink.IsBaseLink = EditorGUILayout.Toggle("Is Base Link", urdfLink.IsBaseLink);
            GUILayout.Space(5);

            EditorGUILayout.BeginVertical("HelpBox");
            jointType = (UrdfJoint.JointTypes)EditorGUILayout.EnumPopup(
                "Child Joint Type", jointType);

            if (GUILayout.Button("Add child link (with joint)"))
            {
                UrdfLink childLink = UrdfLinkExtensions.Create(urdfLink.transform);
                UrdfJoint.Create(childLink.gameObject, jointType);
            }
            EditorGUILayout.EndVertical();
        }
コード例 #7
0
        private static void ImportLinkData(this UrdfLink urdfLink, Link link, Joint joint)
        {
            if (link.inertial == null && joint == null)
            {
                urdfLink.IsBaseLink = true;
            }

            urdfLink.gameObject.name = link.name;

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

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

                if (joint != null)
                {
                    UrdfJoint.Synchronize(urdfLink.gameObject, UrdfJoint.GetJointType(joint.type), joint);
                }
            }
            else if (joint != null)
            {
                Debug.LogWarning("No Joint Component will be created in GameObject \"" + urdfLink.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", urdfLink.gameObject);
            }

            foreach (Joint childJoint in link.joints.Where(x => x.ChildLink != null))
            {
                Link child = childJoint.ChildLink;
                UrdfLinkExtensions.Synchronize(urdfLink.transform, child, childJoint);
            }

            var           linkChildren      = Utils.GetComponentsInDirectChildrenFromGameobject <UrdfLink>(urdfLink.gameObject);
            List <string> wantedObjectNames = link.joints
                                              .Where(x => x.ChildLink != null)
                                              .Select(x => String.IsNullOrEmpty(x.child) ? Utils.GenerateNonReferenceID(x.ChildLink) : x.child)
                                              .ToList();

            linkChildren.RemoveAll(x => wantedObjectNames.Contains(x.name));
            Utils.DestroyAll(linkChildren.Select(x => x.gameObject));
        }
コード例 #8
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>();

            UrdfVisualsExtensions.Create(linkObject.transform, link?.visuals);
            UrdfCollisionsExtensions.Create(linkObject.transform, link?.collisions);

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

            return(urdfLink);
        }
コード例 #9
0
ファイル: UrdfLinkEditor.cs プロジェクト: Kenjiro56/ROS-GUI-1
 protected virtual void OnEnable()
 {
     urdfLink = (UrdfLink)serializedObject.targetObject;
 }