kdl_parser: switch from TinyXML to TinyXML2 (#4)
* kdl_parser: switch from TinyXML to TinyXML2 The library TinyXML is considered to be unmaintained and since all future development is focused on TinyXML2 this patch updates kdl_parser to use TinyXML2. Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com> * Switch to using initString() for parsing in the TiXmlDocument API. This gets rid of a deprecation message when building against newer urdf. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Switch to const pointers for the tinyxml2 versions of the APIs. This matches what we are doing in URDF and what tinyxml2 itself does. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
This commit is contained in:
parent
07221fdc64
commit
afd6aa35de
|
@ -10,8 +10,9 @@ find_package(catkin REQUIRED
|
|||
)
|
||||
find_package(orocos_kdl REQUIRED)
|
||||
find_package(TinyXML REQUIRED)
|
||||
find_package(TinyXML2 REQUIRED)
|
||||
|
||||
include_directories(include ${orocos_kdl_INCLUDE_DIRS} ${TinyXML_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
|
||||
include_directories(include ${orocos_kdl_INCLUDE_DIRS} ${TinyXML_INCLUDE_DIRS} ${TinyXML2_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
|
||||
|
||||
link_directories(${catkin_LIBRARY_DIRS})
|
||||
link_directories(${Boost_LIBRARY_DIRS})
|
||||
|
@ -22,12 +23,12 @@ catkin_package(
|
|||
LIBRARIES ${PROJECT_NAME} ${orocos_kdl_LIBRARIES}
|
||||
INCLUDE_DIRS include
|
||||
CATKIN_DEPENDS rosconsole urdf
|
||||
DEPENDS orocos_kdl TinyXML
|
||||
DEPENDS orocos_kdl TinyXML TinyXML2
|
||||
)
|
||||
|
||||
add_library(${PROJECT_NAME} src/kdl_parser.cpp)
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
${TinyXML_LIBRARIES} ${orocos_kdl_LIBRARIES} ${catkin_LIBRARIES}
|
||||
${TinyXML_LIBRARIES} ${TinyXML2_LIBRARIES} ${orocos_kdl_LIBRARIES} ${catkin_LIBRARIES}
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <kdl/tree.hpp>
|
||||
#include <string>
|
||||
#include <urdf_model/model.h>
|
||||
#include <tinyxml2.h>
|
||||
#include <tinyxml.h> // NOLINT
|
||||
|
||||
#include "kdl_parser/visibility_control.hpp"
|
||||
|
@ -64,19 +65,28 @@ KDL_PARSER_PUBLIC
|
|||
bool treeFromParam(const std::string & param, KDL::Tree & tree);
|
||||
|
||||
/** Constructs a KDL tree from a string containing xml
|
||||
* \param xml A string containting the xml description of the robot
|
||||
* \param xml A string containing the xml description of the robot
|
||||
* \param tree The resulting KDL Tree
|
||||
* returns true on success, false on failure
|
||||
*/
|
||||
KDL_PARSER_PUBLIC
|
||||
bool treeFromString(const std::string & xml, KDL::Tree & tree);
|
||||
|
||||
/** Constructs a KDL tree from a TiXmlDocument
|
||||
* \param xml_doc The TiXmlDocument containting the xml description of the robot
|
||||
* \param tree The resulting KDL Tree
|
||||
/** Constructs a KDL tree from a TinyXML2 document
|
||||
* \param[in] xml_doc The document containing the xml description of the robot
|
||||
* \param[out] tree The resulting KDL Tree
|
||||
* \return true on success, false on failure
|
||||
*/
|
||||
KDL_PARSER_PUBLIC
|
||||
bool treeFromXml(const tinyxml2::XMLDocument * xml_doc, KDL::Tree & tree);
|
||||
|
||||
/** Constructs a KDL tree from a TinyXML document
|
||||
* \param[in] xml_doc The document containing the xml description of the robot
|
||||
* \param[out] tree The resulting KDL Tree
|
||||
* returns true on success, false on failure
|
||||
*/
|
||||
KDL_PARSER_PUBLIC
|
||||
KDL_PARSER_DEPRECATED("TinyXML API is deprecated, use the TinyXML2 version instead")
|
||||
bool treeFromXml(TiXmlDocument * xml_doc, KDL::Tree & tree);
|
||||
|
||||
/** Constructs a KDL tree from a URDF robot model
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
|
||||
// https://gcc.gnu.org/wiki/Visibility
|
||||
|
||||
#define KDL_PARSER_DEPRECATED(msg) __attribute__((deprecated(msg)))
|
||||
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#ifdef __GNUC__
|
||||
#define KDL_PARSER_EXPORT __attribute__ ((dllexport))
|
||||
|
|
|
@ -21,20 +21,20 @@
|
|||
<url type="bugtracker">https://github.com/ros/kdl_parser/issues</url>
|
||||
|
||||
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
|
||||
<depend>urdf</depend>
|
||||
|
||||
<depend version_gte="1.3.0">orocos_kdl</depend>
|
||||
|
||||
<build_depend>cmake_modules</build_depend>
|
||||
<build_depend>liburdfdom-headers-dev</build_depend>
|
||||
<build_depend>rosconsole</build_depend>
|
||||
<build_depend>tinyxml</build_depend>
|
||||
|
||||
<build_export_depend>liburdfdom-headers-dev</build_export_depend>
|
||||
<build_export_depend>tinyxml</build_export_depend>
|
||||
|
||||
<exec_depend>rosconsole</exec_depend>
|
||||
<exec_depend>tinyxml</exec_depend>
|
||||
|
||||
<depend>tinyxml</depend>
|
||||
<depend>tinyxml2</depend>
|
||||
<depend>urdf</depend>
|
||||
|
||||
<test_depend>roscpp</test_depend>
|
||||
<test_depend>rostest</test_depend>
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
|
||||
namespace kdl_parser
|
||||
{
|
||||
|
||||
// construct vector
|
||||
KDL::Vector toKdl(urdf::Vector3 v)
|
||||
{
|
||||
|
@ -160,8 +159,8 @@ bool addChildrenToTree(urdf::LinkConstSharedPtr root, KDL::Tree & tree)
|
|||
|
||||
bool treeFromFile(const std::string & file, KDL::Tree & tree)
|
||||
{
|
||||
TiXmlDocument urdf_xml;
|
||||
urdf_xml.LoadFile(file);
|
||||
tinyxml2::XMLDocument urdf_xml;
|
||||
urdf_xml.LoadFile(file.c_str());
|
||||
return treeFromXml(&urdf_xml, tree);
|
||||
}
|
||||
|
||||
|
@ -177,12 +176,12 @@ bool treeFromParam(const std::string & param, KDL::Tree & tree)
|
|||
|
||||
bool treeFromString(const std::string & xml, KDL::Tree & tree)
|
||||
{
|
||||
TiXmlDocument urdf_xml;
|
||||
tinyxml2::XMLDocument urdf_xml;
|
||||
urdf_xml.Parse(xml.c_str());
|
||||
return treeFromXml(&urdf_xml, tree);
|
||||
}
|
||||
|
||||
bool treeFromXml(TiXmlDocument * xml_doc, KDL::Tree & tree)
|
||||
bool treeFromXml(const tinyxml2::XMLDocument * xml_doc, KDL::Tree & tree)
|
||||
{
|
||||
urdf::Model robot_model;
|
||||
if (!robot_model.initXml(xml_doc)) {
|
||||
|
@ -192,6 +191,22 @@ bool treeFromXml(TiXmlDocument * xml_doc, KDL::Tree & tree)
|
|||
return treeFromUrdfModel(robot_model, tree);
|
||||
}
|
||||
|
||||
bool treeFromXml(TiXmlDocument * xml_doc, KDL::Tree & tree)
|
||||
{
|
||||
if (!xml_doc) {
|
||||
ROS_ERROR("Could not parse the xml document");
|
||||
return false;
|
||||
}
|
||||
|
||||
urdf::Model robot_model;
|
||||
std::stringstream ss;
|
||||
ss << *xml_doc;
|
||||
if (!robot_model.initString(ss.str())) {
|
||||
ROS_ERROR("Could not generate robot model");
|
||||
return false;
|
||||
}
|
||||
return treeFromUrdfModel(robot_model, tree);
|
||||
}
|
||||
|
||||
bool treeFromUrdfModel(const urdf::ModelInterface & robot_model, KDL::Tree & tree)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue