/// <summary> /// Initializes RobotLinks and sets a boolean to its Visuals dictionary, /// telling whether the model of individual visual was already imported (is type of box, cylinder, capsule) /// or not yet (is mesh - is going to be continually imported from ColladaImporter). /// </summary> public void LoadLinks() { // Get all UrdfLink components in builded Robot foreach (UrdfLink link in RobotModelGameObject.GetComponentsInChildren <UrdfLink>()) { // Get all UrdfVisuals of each UrdfLink GameObject visualsGameObject = link.gameObject.GetComponentInChildren <UrdfVisuals>().gameObject; Dictionary <UrdfVisual, bool> visuals = new Dictionary <UrdfVisual, bool>(); // Traverse each UrdfVisual and set a boolean indicating whether its visual is already loaded (is of some basic type - box, cylinder, capsule) // or is going to be loaded by ColladaImporter (in case its type of mesh) foreach (UrdfVisual visual in visualsGameObject.GetComponentsInChildren <UrdfVisual>()) { visuals.Add(visual, visual.GeometryType == GeometryTypes.Mesh ? false : true); // hide visual if it is mesh.. mesh will be displayed when fully loaded visual.gameObject.SetActive(visual.GeometryType == GeometryTypes.Mesh ? false : true); } UrdfJoint urdfJoint = link.GetComponent <UrdfJoint>(); JointStateWriter jointWriter = null; if (urdfJoint != null) { if (urdfJoint.JointType != UrdfJoint.JointTypes.Fixed) { jointWriter = urdfJoint.transform.AddComponentIfNotExists <JointStateWriter>(); Joints.Add(urdfJoint.JointName, link.gameObject.name); } } Links.Add(link.gameObject.name, new RobotLink(link.gameObject.name, urdfJoint, jointWriter, visuals, is_base_link: link.IsBaseLink)); } }
// Start is called before the first frame update void Start() { writer = GetComponentInParent <JointStateWriter>(); if (writer == null) { Debug.Log("No Writer Component found in Module " + transform.parent.name); } }
public RobotLink(string link_name, UrdfJoint urdf_joint, JointStateWriter joint_writer, Dictionary <UrdfVisual, bool> visuals_gameObject = null, bool is_base_link = false) { LinkName = link_name; UrdfJoint = urdf_joint; jointWriter = joint_writer; Visuals = visuals_gameObject ?? new Dictionary <UrdfVisual, bool>(); IsBaseLink = is_base_link; }
public RobotLink(string link_name, UrdfJoint urdf_joint, JointStateWriter joint_writer, JointStateReader joint_reader, Dictionary <UrdfVisual, bool> visuals_gameObject = null, Dictionary <UrdfCollision, bool> collisions_gameObject = null, bool is_base_link = false, float scale = 1f) { LinkName = link_name; UrdfJoint = urdf_joint; jointWriter = joint_writer; jointReader = joint_reader; Visuals = visuals_gameObject ?? new Dictionary <UrdfVisual, bool>(); Collisions = collisions_gameObject ?? new Dictionary <UrdfCollision, bool>(); IsBaseLink = is_base_link; LinkScale = scale; }
void Start() { Register(); yawWriter = yaw.GetComponent <JointStateWriter>(); if (yawWriter == null) { Debug.Log("No Writer Component found in Module " + transform.parent.name); } pitchWriter = pitch.GetComponent <JointStateWriter>(); if (pitchWriter == null) { Debug.Log("No Writer Component found in Module " + transform.parent.name); } }
void Start() { Register(); leftWriter = leftHand.GetComponent <JointStateWriter>(); if (leftWriter == null) { Debug.Log("No Writer Component found in Module " + transform.parent.name); } rightWriter = rightHand.GetComponent <JointStateWriter>(); if (rightWriter == null) { Debug.Log("No Writer Component found in Module " + transform.parent.name); } }
// Use this for initialization void Start() { joint = GetComponent <JointStateWriter>(); newState = 0.0f; }