diff --git a/kdl_parser/CMakeLists.txt b/kdl_parser/CMakeLists.txt index 2bd8fce..bc12b36 100644 --- a/kdl_parser/CMakeLists.txt +++ b/kdl_parser/CMakeLists.txt @@ -23,13 +23,13 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) #uncomment if you have defined services #gensrv() -rosbuild_add_library(${PROJECT_NAME} src/xml_parser.cpp src/dom_parser.cpp) +rosbuild_add_library(${PROJECT_NAME} src/xml_parser.cpp src/kdl_parser.cpp) rosbuild_add_executable(example_xml test/example_xml.cpp ) target_link_libraries(example_xml ${PROJECT_NAME}) -rosbuild_add_executable(example_dom test/example_dom.cpp ) -target_link_libraries(example_dom ${PROJECT_NAME}) +rosbuild_add_executable(example test/example.cpp ) +target_link_libraries(example ${PROJECT_NAME}) rosbuild_add_executable(test_parser test/test_kdl_parser.cpp ) target_link_libraries(test_parser ${PROJECT_NAME}) diff --git a/kdl_parser/include/kdl_parser/dom_parser.hpp b/kdl_parser/include/kdl_parser/dom_parser.hpp index 31d6af4..c29d67c 100644 --- a/kdl_parser/include/kdl_parser/dom_parser.hpp +++ b/kdl_parser/include/kdl_parser/dom_parser.hpp @@ -1,61 +1,4 @@ -/********************************************************************* -* Software License Agreement (BSD License) -* -* Copyright (c) 2008, Willow Garage, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of the Willow Garage nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -*********************************************************************/ -/* Author: Wim Meeussen */ +#warning ____YOU ARE INCLUDING THE DEPRECATED KDL PARSER. PLEASE SWITCH TO THE NEW KDL PARSER. SEE www.ros.org/wiki/kdl_parser FOR DETAILS____ -#ifndef DOM_PARSER_H -#define DOM_PARSER_H - -#include -#include -#include - -using namespace std; - -namespace kdl_parser{ - -/// Constructs a KDL tree from a file, given the file name -bool treeFromFile(const string& file, KDL::Tree& tree); - -/// Constructs a KDL tree from a string containing xml -bool treeFromString(const string& xml, KDL::Tree& tree); - -/// Constructs a KDL tree from a TiXmlDocument -bool treeFromXml(TiXmlDocument *xml_doc, KDL::Tree& tree); - -/// Constructs a KDL tree from a URDF robot model -bool treeFromRobotModel(urdf::Model& robot_model, KDL::Tree& tree); -} - -#endif +#include diff --git a/kdl_parser/include/kdl_parser/kdl_parser.hpp b/kdl_parser/include/kdl_parser/kdl_parser.hpp new file mode 100644 index 0000000..de84705 --- /dev/null +++ b/kdl_parser/include/kdl_parser/kdl_parser.hpp @@ -0,0 +1,86 @@ +/********************************************************************* +* Software License Agreement (BSD License) +* +* Copyright (c) 2008, Willow Garage, Inc. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. +* * Neither the name of the Willow Garage nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +*********************************************************************/ + +/* Author: Wim Meeussen */ + +#ifndef KDL_PARSER_H +#define KDL_PARSER_H + +#include +#include +#include + +using namespace std; + +namespace kdl_parser{ + +/** Constructs a KDL tree from a file, given the file name + * \param file The filename from where to read the xml + * \param tree The resulting KDL Tree + * returns true on success, false on failure + */ +bool treeFromFile(const string& file, KDL::Tree& tree); + +/** Constructs a KDL tree from a string containing xml + * \param xml A string containting the xml description of the robot + * \param tree The resulting KDL Tree + * returns true on success, false on failure + */ +bool treeFromString(const 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 + * returns true on success, false on failure + */ +bool treeFromXml(TiXmlDocument *xml_doc, KDL::Tree& tree); + + +/** Constructs a KDL tree from a URDF robot model + * \param robot_model The URDF robot model + * \param tree The resulting KDL Tree + * returns true on success, false on failure + */ +bool treeFromRobotModel(const urdf::Model& robot_model, KDL::Tree& tree); + + +/** Constructs a KDL tree from a URDF robot model + * \param robot_model The URDF robot model + * \param tree The resulting KDL Tree + * returns true on success, false on failure + */ +bool treeFromUrdfModel(const urdf::Model& robot_model, KDL::Tree& tree); +} + +#endif diff --git a/kdl_parser/manifest.xml b/kdl_parser/manifest.xml index 571b60e..76f390a 100644 --- a/kdl_parser/manifest.xml +++ b/kdl_parser/manifest.xml @@ -6,7 +6,7 @@ Wim Meeussen meeussen@willowgarage.com BSD - + http://pr.willowgarage.com/wiki/ diff --git a/kdl_parser/src/dom_parser.cpp b/kdl_parser/src/kdl_parser.cpp similarity index 93% rename from kdl_parser/src/dom_parser.cpp rename to kdl_parser/src/kdl_parser.cpp index a9b75dd..a6d5858 100644 --- a/kdl_parser/src/dom_parser.cpp +++ b/kdl_parser/src/kdl_parser.cpp @@ -34,7 +34,7 @@ /* Author: Wim Meeussen */ -#include "kdl_parser/dom_parser.hpp" +#include "kdl_parser/kdl_parser.hpp" #include @@ -151,11 +151,11 @@ bool treeFromXml(TiXmlDocument *xml_doc, Tree& tree) ROS_ERROR("Could not generate robot model"); return false; } - return treeFromRobotModel(robot_model, tree); + return treeFromUrdfModel(robot_model, tree); } -bool treeFromRobotModel(urdf::Model& robot_model, Tree& tree) +bool treeFromUrdfModel(const urdf::Model& robot_model, Tree& tree) { tree = Tree(robot_model.getRoot()->name); @@ -167,6 +167,11 @@ bool treeFromRobotModel(urdf::Model& robot_model, Tree& tree) return true; } +bool treeFromRobotModel(const urdf::Model& robot_model, Tree& tree) +{ + ROS_ERROR("treeFromRobotModel function is deprecated and replaces by treeFromUrdfModel"); + return treeFromUrdfModel(robot_model, tree); +} } diff --git a/kdl_parser/test/example_dom.cpp b/kdl_parser/test/example.cpp similarity index 97% rename from kdl_parser/test/example_dom.cpp rename to kdl_parser/test/example.cpp index f19f718..edb3a76 100644 --- a/kdl_parser/test/example_dom.cpp +++ b/kdl_parser/test/example.cpp @@ -36,7 +36,7 @@ #include #include -#include "kdl_parser/dom_parser.hpp" +#include "kdl_parser/kdl_parser.hpp" #include using namespace KDL; @@ -50,7 +50,7 @@ int main() {cerr << "Could not generate robot model" << endl; return false;} Tree my_tree; - if (!kdl_parser::treeFromRobotModel(robot_model, my_tree)) + if (!kdl_parser::treeFromUrdfModel(robot_model, my_tree)) {cerr << "Could not extract kdl tree" << endl; return false;} // walk through tree diff --git a/kdl_parser/test/test_kdl_parser.cpp b/kdl_parser/test/test_kdl_parser.cpp index 7a09bfd..d301058 100644 --- a/kdl_parser/test/test_kdl_parser.cpp +++ b/kdl_parser/test/test_kdl_parser.cpp @@ -37,7 +37,7 @@ #include #include #include -#include "kdl_parser/dom_parser.hpp" +#include "kdl_parser/kdl_parser.hpp" using namespace kdl_parser;