Fawkes API Fawkes Development Version
kdl_parser.h
1/***************************************************************************
2 * kdl_parser.h - KDL Parser
3 *
4 * Created: Fri Feb 14 17:35:15 2014
5 * Copyright 2014 Till Hofmann
6 *
7 ****************************************************************************/
8
9/* This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Library General Public License for more details.
18 *
19 * Read the full text in the LICENSE.GPL file in the doc directory.
20 */
21
22/* This code is based on ROS kdl_parser with the following copyright and license:
23 * Software License Agreement (BSD License)
24 *
25 * Copyright (c) 2008, Willow Garage, Inc.
26 * All rights reserved.
27 *
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
30 * are met:
31 *
32 * * Redistributions of source code must retain the above copyright
33 * notice, this list of conditions and the following disclaimer.
34 * * Redistributions in binary form must reproduce the above
35 * copyright notice, this list of conditions and the following
36 * disclaimer in the documentation and/or other materials provided
37 * with the distribution.
38 * * Neither the name of the Willow Garage nor the names of its
39 * contributors may be used to endorse or promote products derived
40 * from this software without specific prior written permission.
41 *
42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
45 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
46 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
47 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
48 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
50 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
52 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
53 * POSSIBILITY OF SUCH DAMAGE.
54 */
55
56#ifndef KDL_PARSER_H
57#define KDL_PARSER_H
58
59#include <urdf_model/model.h>
60
61#include <kdl/tree.hpp>
62#include <string>
63#include <tinyxml.h>
64
65#if !defined(HAVE_URDFDOM_TYPES_H)
66namespace urdf {
67typedef boost::shared_ptr<urdf::Joint> JointSharedPtr;
68typedef boost::shared_ptr<urdf::Inertial> InertialSharedPtr;
69typedef boost::shared_ptr<urdf::Link> LinkSharedPtr;
70typedef boost::shared_ptr<urdf::ModelInterface> ModelInterfaceSharedPtr;
71} // namespace urdf
72#endif
73
74namespace fawkes {
75
76namespace kdl_parser {
77
78/** Constructs a KDL tree from a file, given the file name
79 * @param file The filename from where to read the xml
80 * @param tree The resulting KDL Tree
81 * @return true on success, false on failure
82 */
83bool tree_from_file(const std::string &file, KDL::Tree &tree);
84
85/** Constructs a KDL tree from the parameter server, given the parameter name
86 * @param param the name of the parameter on the parameter server
87 * @param tree The resulting KDL Tree
88 * @return true on success, false on failure
89 */
90bool tree_from_param(const std::string &param, KDL::Tree &tree);
91
92/** Constructs a KDL tree from a string containing xml
93 * @param xml A string containting the xml description of the robot
94 * @param tree The resulting KDL Tree
95 * returns true on success, false on failure
96 */
97bool tree_from_string(const std::string &xml, KDL::Tree &tree);
98
99/** Constructs a KDL tree from a TiXmlDocument
100 * @param xml_doc The TiXmlDocument containting the xml description of the robot
101 * @param tree The resulting KDL Tree
102 * @return true on success, false on failure
103 */
104bool tree_from_xml(TiXmlDocument *xml_doc, KDL::Tree &tree);
105
106/** Constructs a KDL tree from a URDF robot model
107 * @param robot_model The URDF robot model
108 * @param tree The resulting KDL Tree
109 * @return true on success, false on failure
110 */
111bool tree_from_urdf_model(const urdf::ModelInterface &robot_model, KDL::Tree &tree);
112} // namespace kdl_parser
113
114} // namespace fawkes
115
116#endif
Fawkes library namespace.