Blender V4.3
tree.hpp
Go to the documentation of this file.
1// Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
2
3// Version: 1.0
4// Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
5// Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
6// URL: http://www.orocos.org/kdl
7
8// This library is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Lesser General Public
10// License as published by the Free Software Foundation; either
11// version 2.1 of the License, or (at your option) any later version.
12
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// Lesser General Public License for more details.
17
18// You should have received a copy of the GNU Lesser General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
22#ifndef KDL_TREE_HPP
23#define KDL_TREE_HPP
24
25#include "segment.hpp"
26#include "chain.hpp"
27
28#include <string>
29#include <map>
30#include <Eigen/Core>
31
32namespace KDL
33{
34 //Forward declaration
35 class TreeElement;
36 // Eigen allocator is needed for alignment of Eigen data types
37 typedef std::map<std::string,TreeElement, std::less<std::string>, Eigen::aligned_allocator<std::pair<const std::string, TreeElement> > > SegmentMap;
38
40 {
41 public:
43 {};
44 public:
46 unsigned int q_nr;
47 SegmentMap::value_type const *parent;
48 std::vector<SegmentMap::const_iterator > children;
49 TreeElement(const Segment& segment_in,const SegmentMap::value_type& parent_in,unsigned int q_nr_in)
50 {
51 q_nr=q_nr_in;
52 segment=segment_in;
53 parent=&parent_in;
54 };
56 {
57 return TreeElement();
58 };
59 };
60
67 class Tree
68 {
69 private:
70 SegmentMap segments;
71 unsigned int nrOfJoints;
72 unsigned int nrOfSegments;
73
74 bool addTreeRecursive(SegmentMap::const_iterator root, const std::string& tree_name, const std::string& hook_name);
75
76 public:
80 Tree();
81 Tree(const Tree& in);
82 Tree& operator= (const Tree& arg);
83
95 bool addSegment(const Segment& segment, const std::string& segment_name, const std::string& hook_name);
96
108 bool addChain(const Chain& chain, const std::string& chain_name, const std::string& hook_name);
109
121 bool addTree(const Tree& tree, const std::string& tree_name,const std::string& hook_name);
122
131 unsigned int getNrOfJoints()const
132 {
133 return nrOfJoints;
134 };
135
140 unsigned int getNrOfSegments()const {return nrOfSegments;};
141
149 SegmentMap::const_iterator getSegment(const std::string& segment_name)const
150 {
151 return segments.find(segment_name);
152 };
153
154 SegmentMap::value_type const* getSegmentPtr(const std::string& segment_name)const
155 {
156 SegmentMap::const_iterator it = segments.find(segment_name);
157
158 if (it == segments.end())
159 return 0;
160
161 return &*it;
162 };
163
165 {
166 return segments;
167 }
168
169 virtual ~Tree(){};
170 };
171}
172#endif
173
174
175
176
177
This class encapsulates a serial kinematic interconnection structure. It is build out of segments.
Definition chain.hpp:36
This class encapsulates a simple segment, that is a "rigid body" (i.e., a frame and an inertia) with ...
Definition segment.hpp:46
TreeElement(const Segment &segment_in, const SegmentMap::value_type &parent_in, unsigned int q_nr_in)
Definition tree.hpp:49
unsigned int q_nr
Definition tree.hpp:46
static TreeElement Root()
Definition tree.hpp:55
Segment segment
Definition tree.hpp:45
SegmentMap::value_type const * parent
Definition tree.hpp:47
std::vector< SegmentMap::const_iterator > children
Definition tree.hpp:48
This class encapsulates a tree kinematic interconnection structure. It is build out of segments.
Definition tree.hpp:68
Tree & operator=(const Tree &arg)
Definition tree.cpp:48
bool addTree(const Tree &tree, const std::string &tree_name, const std::string &hook_name)
Definition tree.cpp:98
SegmentMap::const_iterator getSegment(const std::string &segment_name) const
Definition tree.hpp:149
bool addSegment(const Segment &segment, const std::string &segment_name, const std::string &hook_name)
Definition tree.cpp:59
unsigned int getNrOfSegments() const
Definition tree.hpp:140
const SegmentMap & getSegments() const
Definition tree.hpp:164
virtual ~Tree()
Definition tree.hpp:169
bool addChain(const Chain &chain, const std::string &chain_name, const std::string &hook_name)
Definition tree.cpp:83
SegmentMap::value_type const * getSegmentPtr(const std::string &segment_name) const
Definition tree.hpp:154
unsigned int getNrOfJoints() const
Definition tree.hpp:131
KDTree_3d * tree
Definition chain.cpp:27
std::map< std::string, TreeElement, std::less< std::string >, Eigen::aligned_allocator< std::pair< const std::string, TreeElement > > > SegmentMap
Definition tree.hpp:37