api review kdl_parser
This commit is contained in:
parent
64b62bae13
commit
98cc89c86f
|
@ -23,13 +23,13 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
|
||||||
#uncomment if you have defined services
|
#uncomment if you have defined services
|
||||||
#gensrv()
|
#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 )
|
rosbuild_add_executable(example_xml test/example_xml.cpp )
|
||||||
target_link_libraries(example_xml ${PROJECT_NAME})
|
target_link_libraries(example_xml ${PROJECT_NAME})
|
||||||
|
|
||||||
rosbuild_add_executable(example_dom test/example_dom.cpp )
|
rosbuild_add_executable(example test/example.cpp )
|
||||||
target_link_libraries(example_dom ${PROJECT_NAME})
|
target_link_libraries(example ${PROJECT_NAME})
|
||||||
|
|
||||||
rosbuild_add_executable(test_parser test/test_kdl_parser.cpp )
|
rosbuild_add_executable(test_parser test/test_kdl_parser.cpp )
|
||||||
target_link_libraries(test_parser ${PROJECT_NAME})
|
target_link_libraries(test_parser ${PROJECT_NAME})
|
||||||
|
|
|
@ -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
|
#include <kdl_parser/kdl_parser.hpp>
|
||||||
#define DOM_PARSER_H
|
|
||||||
|
|
||||||
#include <kdl/tree.hpp>
|
|
||||||
#include <string>
|
|
||||||
#include <urdf/model.h>
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
@ -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 <kdl/tree.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <urdf/model.h>
|
||||||
|
|
||||||
|
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
|
|
@ -6,7 +6,7 @@
|
||||||
</description>
|
</description>
|
||||||
<author>Wim Meeussen meeussen@willowgarage.com </author>
|
<author>Wim Meeussen meeussen@willowgarage.com </author>
|
||||||
<license>BSD</license>
|
<license>BSD</license>
|
||||||
<review status="unreviewed" notes=""/>
|
<review status="API cleared" notes=""/>
|
||||||
<url>http://pr.willowgarage.com/wiki/</url>
|
<url>http://pr.willowgarage.com/wiki/</url>
|
||||||
|
|
||||||
<depend package="kdl" />
|
<depend package="kdl" />
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
/* Author: Wim Meeussen */
|
/* Author: Wim Meeussen */
|
||||||
|
|
||||||
#include "kdl_parser/dom_parser.hpp"
|
#include "kdl_parser/kdl_parser.hpp"
|
||||||
#include <kdl/frames_io.hpp>
|
#include <kdl/frames_io.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
@ -151,11 +151,11 @@ bool treeFromXml(TiXmlDocument *xml_doc, Tree& tree)
|
||||||
ROS_ERROR("Could not generate robot model");
|
ROS_ERROR("Could not generate robot model");
|
||||||
return false;
|
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);
|
tree = Tree(robot_model.getRoot()->name);
|
||||||
|
|
||||||
|
@ -167,6 +167,11 @@ bool treeFromRobotModel(urdf::Model& robot_model, Tree& tree)
|
||||||
return true;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
#include <kdl/chainfksolverpos_recursive.hpp>
|
#include <kdl/chainfksolverpos_recursive.hpp>
|
||||||
#include <kdl/frames_io.hpp>
|
#include <kdl/frames_io.hpp>
|
||||||
#include "kdl_parser/dom_parser.hpp"
|
#include "kdl_parser/kdl_parser.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace KDL;
|
using namespace KDL;
|
||||||
|
@ -50,7 +50,7 @@ int main()
|
||||||
{cerr << "Could not generate robot model" << endl; return false;}
|
{cerr << "Could not generate robot model" << endl; return false;}
|
||||||
|
|
||||||
Tree my_tree;
|
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;}
|
{cerr << "Could not extract kdl tree" << endl; return false;}
|
||||||
|
|
||||||
// walk through tree
|
// walk through tree
|
|
@ -37,7 +37,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ros/ros.h>
|
#include <ros/ros.h>
|
||||||
#include "kdl_parser/dom_parser.hpp"
|
#include "kdl_parser/kdl_parser.hpp"
|
||||||
|
|
||||||
using namespace kdl_parser;
|
using namespace kdl_parser;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue