Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update URDF parser to use Tesseract XML namespace #1081

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tesseract_support/urdf/lbr_iiwa_14_r820.urdf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- | This document was autogenerated by xacro from lbr_iiwa_14_r820.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<robot name="kuka_lbr_iiwa_14_r820" xmlns:xacro="http://wiki.ros.org/xacro">
<robot name="kuka_lbr_iiwa_14_r820" xmlns:xacro="http://wiki.ros.org/xacro" tesseract:make_convex="true">
<!-- link list -->
<link name="base_link">
<visual>
Expand Down
2 changes: 1 addition & 1 deletion tesseract_support/urdf/lbr_iiwa_14_r820.xacro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<robot name="kuka_lbr_iiwa_14_r820" xmlns:xacro="http://wiki.ros.org/xacro">
<robot name="kuka_lbr_iiwa_14_r820" xmlns:xacro="http://wiki.ros.org/xacro" tesseract:make_convex="true">
<xacro:include filename="$(find tesseract_support)/urdf/lbr_iiwa_14_r820_macro.xacro"/>
<xacro:kuka_lbr_iiwa_14_r820 prefix=""/>
</robot>
1 change: 0 additions & 1 deletion tesseract_urdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ add_library(
src/capsule.cpp
src/collision.cpp
src/cone.cpp
src/convex_mesh.cpp
src/cylinder.cpp
src/dynamics.cpp
src/geometry.cpp
Expand Down
4 changes: 3 additions & 1 deletion tesseract_urdf/include/tesseract_urdf/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* BOX_ELEMENT_NAME;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Levi-Armstrong this seems to be a problem for windows. Do you know how to handle this for windows? If I don't make it extern, then I get the compiler unused-variable error

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these needed?

Copy link
Contributor

@Levi-Armstrong Levi-Armstrong Jan 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend creating a single header like constants.h and leveraging constexpr std::string_view BOX_ELEMENT_NAME = "box";


/**
* @brief Parse a xml box element
* @param xml_element The xml element
* @return Tesseract Geometry Box
*/
std::shared_ptr<tesseract_geometry::Box> parseBox(const tinyxml2::XMLElement* xml_element, int version);
std::shared_ptr<tesseract_geometry::Box> parseBox(const tinyxml2::XMLElement* xml_element);

tinyxml2::XMLElement* writeBox(const std::shared_ptr<const tesseract_geometry::Box>& box, tinyxml2::XMLDocument& doc);

Expand Down
5 changes: 3 additions & 2 deletions tesseract_urdf/include/tesseract_urdf/calibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* CALIBRATION_ELEMENT_NAME;

/**
* @brief Parse a xml calibration element
* @param xml_element The xml element
* @return Tesseract JointCalibration
*/
std::shared_ptr<tesseract_scene_graph::JointCalibration> parseCalibration(const tinyxml2::XMLElement* xml_element,
int version);
std::shared_ptr<tesseract_scene_graph::JointCalibration> parseCalibration(const tinyxml2::XMLElement* xml_element);

tinyxml2::XMLElement*
writeCalibration(const std::shared_ptr<const tesseract_scene_graph::JointCalibration>& calibration,
Expand Down
4 changes: 3 additions & 1 deletion tesseract_urdf/include/tesseract_urdf/capsule.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* CAPSULE_ELEMENT_NAME;

/**
* @brief Parse a xml capsule element
* @param xml_element The xml element
* @return Tesseract Geometry Capsule
*/
std::shared_ptr<tesseract_geometry::Capsule> parseCapsule(const tinyxml2::XMLElement* xml_element, int version);
std::shared_ptr<tesseract_geometry::Capsule> parseCapsule(const tinyxml2::XMLElement* xml_element);

tinyxml2::XMLElement* writeCapsule(const std::shared_ptr<const tesseract_geometry::Capsule>& capsule,
tinyxml2::XMLDocument& doc);
Expand Down
6 changes: 4 additions & 2 deletions tesseract_urdf/include/tesseract_urdf/collision.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,18 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* COLLISION_ELEMENT_NAME;

/**
* @brief Parse xml element collision
* @param xml_element The xml element
* @param locator The Tesseract resource locator
* @param version The version number
* @param make_convex_meshes Flag to indicate if the meshes should be converted to convex hulls
* @return A Collision object
*/
std::shared_ptr<tesseract_scene_graph::Collision> parseCollision(const tinyxml2::XMLElement* xml_element,
const tesseract_common::ResourceLocator& locator,
int version);
bool make_convex_meshes);

/**
* @brief writeCollision Write collision object to URDF XML
Expand Down
4 changes: 3 additions & 1 deletion tesseract_urdf/include/tesseract_urdf/cone.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* CONE_ELEMENT_NAME;

/**
* @brief Parse a xml cone element
* @param xml_element The xml element
* @return Tesseract Geometry Cone
*/
std::shared_ptr<tesseract_geometry::Cone> parseCone(const tinyxml2::XMLElement* xml_element, int version);
std::shared_ptr<tesseract_geometry::Cone> parseCone(const tinyxml2::XMLElement* xml_element);

tinyxml2::XMLElement* writeCone(const std::shared_ptr<const tesseract_geometry::Cone>& cone,
tinyxml2::XMLDocument& doc);
Expand Down
77 changes: 0 additions & 77 deletions tesseract_urdf/include/tesseract_urdf/convex_mesh.h

This file was deleted.

4 changes: 3 additions & 1 deletion tesseract_urdf/include/tesseract_urdf/cylinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* CYLINDER_ELEMENT_NAME;

/**
* @brief Parse a xml cylinder element
* @param xml_element The xml element
* @return Tesseract Geometry Cylinder
*/
std::shared_ptr<tesseract_geometry::Cylinder> parseCylinder(const tinyxml2::XMLElement* xml_element, int version);
std::shared_ptr<tesseract_geometry::Cylinder> parseCylinder(const tinyxml2::XMLElement* xml_element);

tinyxml2::XMLElement* writeCylinder(const std::shared_ptr<const tesseract_geometry::Cylinder>& cylinder,
tinyxml2::XMLDocument& doc);
Expand Down
5 changes: 3 additions & 2 deletions tesseract_urdf/include/tesseract_urdf/dynamics.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* DYNAMICS_ELEMENT_NAME;

/**
* @brief Parse a xml dynamics element
* @param xml_element The xml element
* @return Tesseract JointDynamics
*/
std::shared_ptr<tesseract_scene_graph::JointDynamics> parseDynamics(const tinyxml2::XMLElement* xml_element,
int version);
std::shared_ptr<tesseract_scene_graph::JointDynamics> parseDynamics(const tinyxml2::XMLElement* xml_element);

tinyxml2::XMLElement* writeDynamics(const std::shared_ptr<const tesseract_scene_graph::JointDynamics>& dynamics,
tinyxml2::XMLDocument& doc);
Expand Down
6 changes: 4 additions & 2 deletions tesseract_urdf/include/tesseract_urdf/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* GEOMETRY_ELEMENT_NAME;

/**
* @brief Parse xml element geometry
* @param xml_element The xml element
* @param locator The Tesseract resource locator
* @param visual Indicate if visual
* @param version The version number
* @param make_convex_meshes Flag to indicate if the meshes should be converted to convex hulls
* @return A Tesseract Geometry
*/
std::shared_ptr<tesseract_geometry::Geometry> parseGeometry(const tinyxml2::XMLElement* xml_element,
const tesseract_common::ResourceLocator& locator,
bool visual,
int version);
bool make_convex_meshes);

/**
* @brief writeGeometry Write geometry to URDF XML
Expand Down
4 changes: 3 additions & 1 deletion tesseract_urdf/include/tesseract_urdf/inertial.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* INERTIAL_ELEMENT_NAME;

/**
* @brief Parse xml element inertial
* @param xml_element The xml element
* @param version The version number
* @return A Tesseract Inertial
*/
std::shared_ptr<tesseract_scene_graph::Inertial> parseInertial(const tinyxml2::XMLElement* xml_element, int version);
std::shared_ptr<tesseract_scene_graph::Inertial> parseInertial(const tinyxml2::XMLElement* xml_element);

tinyxml2::XMLElement* writeInertial(const std::shared_ptr<const tesseract_scene_graph::Inertial>& inertial,
tinyxml2::XMLDocument& doc);
Expand Down
4 changes: 3 additions & 1 deletion tesseract_urdf/include/tesseract_urdf/joint.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* JOINT_ELEMENT_NAME;

/**
* @brief Parse xml element joint
* @param xml_element The xml element
* @param version The version number
* @return A Tesseract Joint
*/
std::shared_ptr<tesseract_scene_graph::Joint> parseJoint(const tinyxml2::XMLElement* xml_element, int version);
std::shared_ptr<tesseract_scene_graph::Joint> parseJoint(const tinyxml2::XMLElement* xml_element);

tinyxml2::XMLElement* writeJoint(const std::shared_ptr<const tesseract_scene_graph::Joint>& joint,
tinyxml2::XMLDocument& doc);
Expand Down
4 changes: 3 additions & 1 deletion tesseract_urdf/include/tesseract_urdf/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* LIMITS_ELEMENT_NAME;

/**
* @brief Parse xml element limits
* @param xml_element The xml element
* @param version The version number
* @return A Tesseract JointLimits
*/
std::shared_ptr<tesseract_scene_graph::JointLimits> parseLimits(const tinyxml2::XMLElement* xml_element, int version);
std::shared_ptr<tesseract_scene_graph::JointLimits> parseLimits(const tinyxml2::XMLElement* xml_element);

tinyxml2::XMLElement* writeLimits(const std::shared_ptr<const tesseract_scene_graph::JointLimits>& limits,
tinyxml2::XMLDocument& doc);
Expand Down
8 changes: 5 additions & 3 deletions tesseract_urdf/include/tesseract_urdf/link.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,21 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* LINK_ELEMENT_NAME;

/**
* @brief Parse xml element link
* @param xml_element The xml element
* @param locator The Tesseract resource locator
* @param available_materials The current available materials
* @param version The version number
* @param make_convex_meshes Flag to indicate if the meshes should be converted to convex hulls
* @return A Tesseract Link
*/
std::shared_ptr<tesseract_scene_graph::Link>
parseLink(const tinyxml2::XMLElement* xml_element,
const tesseract_common::ResourceLocator& locator,
std::unordered_map<std::string, std::shared_ptr<tesseract_scene_graph::Material>>& available_materials,
int version);
bool make_convex_meshes,
std::unordered_map<std::string, std::shared_ptr<tesseract_scene_graph::Material>>& available_materials);

/**
* @brief writeLink Write a link to URDF XML
Expand Down
5 changes: 3 additions & 2 deletions tesseract_urdf/include/tesseract_urdf/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* MATERIAL_ELEMENT_NAME;

/**
* @brief Parse xml element material
* @param xml_element The xml element
Expand All @@ -53,8 +55,7 @@ namespace tesseract_urdf
std::shared_ptr<tesseract_scene_graph::Material>
parseMaterial(const tinyxml2::XMLElement* xml_element,
std::unordered_map<std::string, std::shared_ptr<tesseract_scene_graph::Material>>& available_materials,
bool allow_anonymous,
int version);
bool allow_anonymous);

tinyxml2::XMLElement* writeMaterial(const std::shared_ptr<const tesseract_scene_graph::Material>& material,
tinyxml2::XMLDocument& doc);
Expand Down
13 changes: 8 additions & 5 deletions tesseract_urdf/include/tesseract_urdf/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,21 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* MESH_ELEMENT_NAME;

/**
* @brief Parse xml element mesh
* @param xml_element The xml element
* @param locator The Tesseract resource locator
* @param visual Indicate if visual
* @param version The version number
* @param make_convex Flag to indicate if the mesh should be converted to a convex hull
* @return A vector of Tesseract Meshes
*/
std::vector<std::shared_ptr<tesseract_geometry::Mesh>> parseMesh(const tinyxml2::XMLElement* xml_element,
const tesseract_common::ResourceLocator& locator,
bool visual,
int version);
std::vector<std::shared_ptr<tesseract_geometry::PolygonMesh>>
parseMesh(const tinyxml2::XMLElement* xml_element,
const tesseract_common::ResourceLocator& locator,
bool visual,
bool make_convex);

/**
* @brief writeMesh Write a mesh to URDF XML and PLY file
Expand Down
4 changes: 3 additions & 1 deletion tesseract_urdf/include/tesseract_urdf/mimic.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ class XMLDocument;

namespace tesseract_urdf
{
extern const char* MIMIC_ELEMENT_NAME;

/**
* @brief Parse xml element mimic
* @param xml_element The xml element
* @param version The version number
* @return A Tesseract JointMimic
*/
std::shared_ptr<tesseract_scene_graph::JointMimic> parseMimic(const tinyxml2::XMLElement* xml_element, int version);
std::shared_ptr<tesseract_scene_graph::JointMimic> parseMimic(const tinyxml2::XMLElement* xml_element);

tinyxml2::XMLElement* writeMimic(const std::shared_ptr<const tesseract_scene_graph::JointMimic>& mimic,
tinyxml2::XMLDocument& doc);
Expand Down
Loading
Loading