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 void Create(Transform parent, Link.Collision collision) { GameObject collisionObject = new GameObject("unnamed"); collisionObject.transform.SetParentAndAlign(parent); UrdfCollision urdfCollision = collisionObject.AddComponent <UrdfCollision>(); urdfCollision.geometryType = UrdfGeometry.GetGeometryType(collision.geometry); UrdfGeometryCollision.Create(collisionObject.transform, urdfCollision.geometryType, collision.geometry); UrdfOrigin.ImportOriginData(collisionObject.transform, collision.origin); }
public static void Create(Transform parent, Link.Visual visual) { GameObject visualObject = new GameObject(visual.name ?? "unnamed"); visualObject.transform.SetParentAndAlign(parent); UrdfVisual urdfVisual = visualObject.AddComponent <UrdfVisual>(); urdfVisual.GeometryType = UrdfGeometry.GetGeometryType(visual.geometry); UrdfGeometryVisual.Create(visualObject.transform, urdfVisual.GeometryType, visual.geometry); UrdfMaterial.SetUrdfMaterial(visualObject, visual.material); UrdfOrigin.ImportOriginData(visualObject.transform, visual.origin); }
public static void Create(Transform parent, Link.Collision collision) { if (String.IsNullOrEmpty(collision.name)) { collision.name = collision.GenerateNonReferenceID(); } if (parent.FindChildOrCreateWithComponent(collision.name, out GameObject collisionObject, out UrdfCollision urdfCollision)) { urdfCollision.geometryType = UrdfGeometry.GetGeometryType(collision.geometry); UrdfGeometryCollision.Create(collisionObject.transform, urdfCollision.geometryType, collision.geometry); UrdfOrigin.ImportOriginData(collisionObject.transform, collision.origin); } }
private static void ImportSimulationLinkData(this GameObject linkObject, Link link, Joint joint) { linkObject.gameObject.name = link.name; if (joint?.origin != null) { UrdfOrigin.ImportOriginData(linkObject.transform, joint.origin); } linkObject.AddComponent <TfFrame>(); foreach (Joint childJoint in link.joints) { Link child = childJoint.ChildLink; Create(linkObject.transform, child, childJoint); } }
public static void Create(Transform parent, Link.Visual visual) { if (String.IsNullOrEmpty(visual.name)) { visual.name = visual.GenerateNonReferenceID(); } if (parent.FindChildOrCreateWithComponent <UrdfVisual>(visual.name, out GameObject visualObject, out UrdfVisual urdfVisual)) { //only create these visuals if the gameobject had to be created itself urdfVisual.GeometryType = UrdfGeometry.GetGeometryType(visual.geometry); UrdfGeometryVisual.Create(visualObject.transform, urdfVisual.GeometryType, visual.geometry); } //update these values every time UrdfMaterial.SetUrdfMaterial(visualObject, visual.material); UrdfOrigin.ImportOriginData(visualObject.transform, visual.origin); }
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)); }
private static void ImportSimulationLinkData(this GameObject linkObject, Link link, Joint joint) { linkObject.gameObject.name = link.name; if (joint?.origin != null) { UrdfOrigin.ImportOriginData(linkObject.transform, joint.origin); } if (link?.inertial != null) { UrdfInertial.Create(linkObject, link.inertial); // TODO(sam): figure out if possible to only let base_footprint be kinematic linkObject.GetComponent <Rigidbody>().isKinematic = true; if (joint != null) { UrdfSimulatedJoint.Create(linkObject, UrdfJoint.GetJointType(joint.type), joint); } } else if (linkObject.name == "base_footprint") { Rigidbody baseFootprintRigidbody = linkObject.AddComponent <Rigidbody>(); baseFootprintRigidbody.useGravity = false; baseFootprintRigidbody.isKinematic = true; } else if (joint != null) { Debug.LogWarning("No Joint Component will be created in GameObject \"" + linkObject.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", linkObject); } foreach (Joint childJoint in link.joints) { Link child = childJoint.ChildLink; Create(linkObject.transform, child, childJoint); } }