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 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 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); }