public static void Create(string filename) { Robot robot = new Robot(); robot.ConstructFromFile(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); UrdfLinkExtensions.Create(robotGameObject.transform, robot.root); GameObjectUtility.SetParentAndAlign(robotGameObject, Selection.activeObject as GameObject); Undo.RegisterCreatedObjectUndo(robotGameObject, "Create " + robotGameObject.name); Selection.activeObject = robotGameObject; }
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); } }
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); } }
public static IEnumerator Create(string filename, ImportSettings settings, bool loadStatus = false) { CreateTag(); importsettings = settings; Robot robot = new Robot(filename); settings.totalLinks = robot.links.Count; if (!UrdfAssetPathHandler.IsValidAssetPath(robot.filename)) { Debug.LogError("URDF file and ressources must be placed in Assets Folder:\n" + Application.dataPath); yield break; } GameObject robotGameObject = new GameObject(robot.name); robotGameObject.tag = tagName; robotGameObject.AddComponent <UrdfRobot>(); robotGameObject.AddComponent <RosSharp.Control.Controller>(); robotGameObject.GetComponent <UrdfRobot>().SetAxis(settings.choosenAxis); UrdfAssetPathHandler.SetPackageRoot(Path.GetDirectoryName(robot.filename)); UrdfMaterial.InitializeRobotMaterials(robot); UrdfPlugins.Create(robotGameObject.transform, robot.plugins); Stack <Tuple <Link, Transform, Joint> > importStack = new Stack <Tuple <Link, Transform, Joint> >(); importStack.Push(new Tuple <Link, Transform, Joint>(robot.root, robotGameObject.transform, null)); while (importStack.Count != 0) { Tuple <Link, Transform, Joint> currentLink = importStack.Pop(); GameObject importedLink = UrdfLinkExtensions.Create(currentLink.Item2, currentLink.Item1, currentLink.Item3); settings.linksLoaded++; foreach (Joint childJoint in currentLink.Item1.joints) { Link child = childJoint.ChildLink; importStack.Push(new Tuple <Link, Transform, Joint>(child, importedLink.transform, childJoint)); } if (loadStatus) { yield return(null); } } GameObjectUtility.SetParentAndAlign(robotGameObject, Selection.activeObject as GameObject); Undo.RegisterCreatedObjectUndo(robotGameObject, "Create " + robotGameObject.name); Selection.activeObject = robotGameObject; CorrectAxis(robotGameObject); CreateCollisionExceptions(robot, robotGameObject); }
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; }
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; }
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(); }
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)); }
public static void Create(string filename, ImportSettings settings) { CreateTag(); importsettings = settings; 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.tag = tagName; robotGameObject.AddComponent <UrdfRobot>(); robotGameObject.AddComponent <RosSharp.Control.Controller>(); robotGameObject.GetComponent <UrdfRobot>().SetAxis(settings.choosenAxis); UrdfAssetPathHandler.SetPackageRoot(Path.GetDirectoryName(robot.filename)); UrdfMaterial.InitializeRobotMaterials(robot); UrdfPlugins.Create(robotGameObject.transform, robot.plugins); UrdfLinkExtensions.Create(robotGameObject.transform, robot.root); GameObjectUtility.SetParentAndAlign(robotGameObject, Selection.activeObject as GameObject); Undo.RegisterCreatedObjectUndo(robotGameObject, "Create " + robotGameObject.name); Selection.activeObject = robotGameObject; CorrectAxis(robotGameObject); CreateCollisionExceptions(robot, robotGameObject); }