bool exportInertial(Inertial &i, TiXmlElement *xml) { // adds <inertial> // <mass value="1"/> // <pose xyz="0 0 0" rpy="0 0 0"/> // <inertia ixx="1" ixy="0" /> // </inertial> TiXmlElement *inertial_xml = new TiXmlElement("inertial"); TiXmlElement *mass_xml = new TiXmlElement("mass"); mass_xml->SetAttribute("value", urdf_export_helpers::values2str(i.mass)); inertial_xml->LinkEndChild(mass_xml); exportPose(i.origin, inertial_xml); TiXmlElement *inertia_xml = new TiXmlElement("inertia"); inertia_xml->SetAttribute("ixx", urdf_export_helpers::values2str(i.ixx)); inertia_xml->SetAttribute("ixy", urdf_export_helpers::values2str(i.ixy)); inertia_xml->SetAttribute("ixz", urdf_export_helpers::values2str(i.ixz)); inertia_xml->SetAttribute("iyy", urdf_export_helpers::values2str(i.iyy)); inertia_xml->SetAttribute("iyz", urdf_export_helpers::values2str(i.iyz)); inertia_xml->SetAttribute("izz", urdf_export_helpers::values2str(i.izz)); inertial_xml->LinkEndChild(inertia_xml); xml->LinkEndChild(inertial_xml); return true; }
bool exportJoint(Joint &joint, TiXmlElement* xml) { TiXmlElement * joint_xml = new TiXmlElement("joint"); joint_xml->SetAttribute("name", joint.name); if (joint.type == urdf::Joint::PLANAR) joint_xml->SetAttribute("type", "planar"); else if (joint.type == urdf::Joint::FLOATING) joint_xml->SetAttribute("type", "floating"); else if (joint.type == urdf::Joint::REVOLUTE) joint_xml->SetAttribute("type", "revolute"); else if (joint.type == urdf::Joint::CONTINUOUS) joint_xml->SetAttribute("type", "continuous"); else if (joint.type == urdf::Joint::PRISMATIC) joint_xml->SetAttribute("type", "prismatic"); else if (joint.type == urdf::Joint::FIXED) joint_xml->SetAttribute("type", "fixed"); else CONSOLE_BRIDGE_logError("ERROR: Joint [%s] type [%d] is not a defined type.\n",joint.name.c_str(), joint.type); // origin exportPose(joint.parent_to_joint_origin_transform, joint_xml); // axis TiXmlElement * axis_xml = new TiXmlElement("axis"); axis_xml->SetAttribute("xyz", urdf_export_helpers::values2str(joint.axis)); joint_xml->LinkEndChild(axis_xml); // parent TiXmlElement * parent_xml = new TiXmlElement("parent"); parent_xml->SetAttribute("link", joint.parent_link_name); joint_xml->LinkEndChild(parent_xml); // child TiXmlElement * child_xml = new TiXmlElement("child"); child_xml->SetAttribute("link", joint.child_link_name); joint_xml->LinkEndChild(child_xml); if (joint.dynamics) exportJointDynamics(*(joint.dynamics), joint_xml); if (joint.limits) exportJointLimits(*(joint.limits), joint_xml); if (joint.safety) exportJointSafety(*(joint.safety), joint_xml); if (joint.calibration) exportJointCalibration(*(joint.calibration), joint_xml); if (joint.mimic) exportJointMimic(*(joint.mimic), joint_xml); xml->LinkEndChild(joint_xml); return true; }
bool exportCollision(Collision &col, TiXmlElement* xml) { // <collision group="default"> // <origin rpy="0 0 0" xyz="0 0 0"/> // <geometry> // <mesh filename="mesh.dae"/> // </geometry> // <material name="Grey"/> // </collision> TiXmlElement * collision_xml = new TiXmlElement("collision"); exportPose(col.origin, collision_xml); exportGeometry(col.geometry, collision_xml); xml->LinkEndChild(collision_xml); return true; }
bool exportVisual(Visual &vis, TiXmlElement *xml) { // <visual group="default"> // <origin rpy="0 0 0" xyz="0 0 0"/> // <geometry> // <mesh filename="mesh.dae"/> // </geometry> // <material name="Grey"/> // </visual> TiXmlElement * visual_xml = new TiXmlElement("visual"); exportPose(vis.origin, visual_xml); exportGeometry(vis.geometry, visual_xml); if (vis.material) exportMaterial(*vis.material, visual_xml); xml->LinkEndChild(visual_xml); return true; }