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 override void OnInspectorGUI() { UrdfPlugins urdfPlugins = (UrdfPlugins)target; GUILayout.Space(8); if (GUILayout.Button("Add Plugin")) { UrdfPlugin.Create(urdfPlugins.transform); } }
public void Synchronize(Robot robot, GameObject rootObject, string assetRoot) { GameObject robotGameObject = rootObject; robotGameObject.AddComponentIfNotExists <UrdfRobot>(); UrdfAssetPathHandler.SetPackageRoot(assetRoot); UrdfMaterial.InitializeRobotMaterials(robot); UrdfPlugins.Synchronize(robotGameObject.transform, robot.plugins); UrdfLinkExtensions.Synchronize(robotGameObject.transform, robot.root); }
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; }
/// <summary> /// Synchronizes the <paramref name="rootObject"/> with the <paramref name="robot"/> /// </summary> /// <param name="robot"></param> /// <param name="rootObject"></param> public void Synchronize(Robot robot, GameObject rootObject) { LocateAssetHandler.SetRobotName(robot.name); GameObject robotGameObject = rootObject; robotGameObject.AddComponentIfNotExists <UrdfRobot>(); UrdfPlugins.Synchronize(robotGameObject.transform, robot.plugins); UrdfLinkExtensions.Synchronize(robotGameObject.transform, robot.root); //These tags are needed for the Camera/Sensors to interact with the gameobject foreach (var child in rootObject.GetComponentsInChildren <Transform>()) { child.gameObject.tag = "Robot"; } }
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); }