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 void GetJointType_AllJointTypes_Succeeds() { Assert.AreEqual(UrdfJoint.JointTypes.Fixed, UrdfJoint.GetJointType("fixed")); Assert.AreEqual(UrdfJoint.JointTypes.Continuous, UrdfJoint.GetJointType("continuous")); Assert.AreEqual(UrdfJoint.JointTypes.Revolute, UrdfJoint.GetJointType("revolute")); Assert.AreEqual(UrdfJoint.JointTypes.Floating, UrdfJoint.GetJointType("floating")); Assert.AreEqual(UrdfJoint.JointTypes.Prismatic, UrdfJoint.GetJointType("prismatic")); Assert.AreEqual(UrdfJoint.JointTypes.Planar, UrdfJoint.GetJointType("planar")); Assert.AreEqual(UrdfJoint.JointTypes.Fixed, UrdfJoint.GetJointType("unknown")); }
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); } }