orocos_kdl
chain.cpp
Go to the documentation of this file.
1 // Copyright (C) 2007 Ruben Smits <ruben dot smits at intermodalics dot eu>
2 
3 // Version: 1.0
4 // Author: Ruben Smits <ruben dot smits at intermodalics dot eu>
5 // Maintainer: Ruben Smits <ruben dot smits at intermodalics dot eu>
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 #include "chain.hpp"
23 
24 namespace KDL {
25 
27  nrOfJoints(0),
28  nrOfSegments(0),
29  segments(0)
30  {
31  }
32 
33  Chain::Chain(const Chain& in):
34  nrOfJoints(0),
35  nrOfSegments(0),
36  segments(0)
37  {
38  for(unsigned int i=0;i<in.getNrOfSegments();i++)
39  this->addSegment(in.getSegment(i));
40  }
41 
43  {
44  nrOfJoints=0;
45  nrOfSegments=0;
46  segments.resize(0);
47  for(unsigned int i=0;i<arg.nrOfSegments;i++)
48  addSegment(arg.getSegment(i));
49  return *this;
50 
51  }
52 
53  void Chain::addSegment(const Segment& segment)
54  {
55  segments.push_back(segment);
56  nrOfSegments++;
57  if(segment.getJoint().getType()!=Joint::Fixed)
58  nrOfJoints++;
59  }
60 
61  void Chain::addChain(const Chain& chain)
62  {
63  for(unsigned int i=0;i<chain.getNrOfSegments();i++)
64  this->addSegment(chain.getSegment(i));
65  }
66 
67  const Segment& Chain::getSegment(unsigned int nr)const
68  {
69  return segments[nr];
70  }
71 
72  Segment& Chain::getSegment(unsigned int nr)
73  {
74  return segments[nr];
75  }
76 
78  {
79  }
80 
81 }
82 
KDL::Chain::nrOfSegments
unsigned int nrOfSegments
Definition: chain.hpp:38
chain.hpp
KDL::Chain::addChain
void addChain(const Chain &chain)
Definition: chain.cpp:61
KDL::Chain::nrOfJoints
unsigned int nrOfJoints
Definition: chain.hpp:37
KDL::Segment::getJoint
const Joint & getJoint() const
Definition: segment.hpp:118
KDL::Chain::segments
std::vector< Segment > segments
Definition: chain.hpp:40
KDL::Joint::Fixed
@ Fixed
Definition: joint.hpp:47
KDL
Definition: kukaLWR_DHnew.cpp:25
KDL::Chain::getNrOfSegments
unsigned int getNrOfSegments() const
Definition: chain.hpp:76
KDL::Chain::operator=
Chain & operator=(const Chain &arg)
Definition: chain.cpp:42
KDL::Chain::Chain
Chain()
Definition: chain.cpp:26
KDL::Chain::getSegment
const Segment & getSegment(unsigned int nr) const
Definition: chain.cpp:67
KDL::Segment
This class encapsulates a simple segment, that is a "rigid body" (i.e., a frame and a rigid body ine...
Definition: segment.hpp:46
KDL::Chain::addSegment
void addSegment(const Segment &segment)
Definition: chain.cpp:53
KDL::Joint::getType
const JointType & getType() const
Definition: joint.hpp:159
KDL::Chain::~Chain
virtual ~Chain()
Definition: chain.cpp:77
KDL::Chain
This class encapsulates a serial kinematic interconnection structure. It is built out of segments.
Definition: chain.hpp:35