Here are the examples of the csharp api System.Collections.Generic.HashSet.Add(ZOSimOccurrence) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
Source : ZOExportURDF.cs
with MIT License
from fsstudio-team
with MIT License
from fsstudio-team
public XDoreplacedent BuildURDF(ZOSimDoreplacedentRoot doreplacedentRoot) {
// create root doreplacedent and robot element
XElement robot = new XElement("robot");
robot.SetAttributeValue("name", doreplacedentRoot.Name);
XML = new XDoreplacedent(robot);
// go through the ZOSimOccurrences and convert into URDF Links and Joints
ZOSimOccurrence simOccurrence = null;
foreach (Transform child in doreplacedentRoot.transform) { // BUG: Should only ever be one base object for URDF!!!
simOccurrence = child.GetComponent<ZOSimOccurrence>();
if (simOccurrence) {
break; // BUG: stops at first sim occurrence
}
}
Matrix4x4 baseTransform = doreplacedentRoot.transform.WorldTranslationRotationMatrix();
List<URDFJoint> joints = new List<URDFJoint>();
BuildURDFJoints(robot, null, simOccurrence, baseTransform, ref joints);
// build links
HashSet<ZOSimOccurrence> links = new HashSet<ZOSimOccurrence>();
foreach (URDFJoint joint in joints) {
if (links.Contains(joint.Parent) == false) { // build parent link if not exist
Vector3 offset = -1.0f * joint.ConnectedAnchor;
if (joints[0] == joint) { // if base joint do not apply any offset to parent link
offset = Vector3.zero;
}
BuildLink(joint.Parent, robot, offset);
links.Add(joint.Parent);
}
if (links.Contains(joint.Child) == false) { // build child link if not exist
Vector3 offset = -1.0f * joint.ConnectedAnchor;
BuildLink(joint.Child, robot, offset);
links.Add(joint.Child);
}
}
if (joints.Count == 0) { // if we don't have any joints then create a dummy world link and joint to first link
XElement link = new XElement("link");
link.SetAttributeValue("name", "World");
robot.Add(link);
BuildLink(simOccurrence, robot, Vector3.zero);
XElement jointX = new XElement("joint");
jointX.SetAttributeValue("name", $"World_to_{simOccurrence.Name}");
jointX.SetAttributeValue("type", "fixed");
XElement parentX = new XElement("parent");
parentX.SetAttributeValue("link", "World");
jointX.Add(parentX);
XElement childX = new XElement("child");
childX.SetAttributeValue("link", simOccurrence.Name);
jointX.Add(childX);
robot.Add(jointX);
}
return XML;
}