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; }
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 CreateFromString(string urdfString) { Robot robot = new Robot(); robot.ConstructFromString(urdfString); UrdfAssetPathHandler.SetPackageRoot(Application.dataPath + "/Urdf/FromString"); Create(robot); }
public static void CreateFromFile(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; } UrdfAssetPathHandler.SetPackageRoot(Path.GetDirectoryName(robot.filename)); Create(robot); }
private static string LocateRootAssetFolder <T>(string urdfFileName) where T : UnityEngine.Object { string newAssetPath = EditorUtility.OpenFolderPanel( "Locate package root folder", Path.Combine(Path.GetDirectoryName(Application.dataPath), "Assets"), ""); if (UrdfAssetPathHandler.IsValidAssetPath(newAssetPath)) { UrdfAssetPathHandler.SetPackageRoot(newAssetPath, true); } else { Debug.LogWarning("Selected package root " + newAssetPath + " is not within the Assets folder."); } return(UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath(urdfFileName)); }
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); }