chain.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /** \file itasc/kdl/chain.cpp
  2. * \ingroup itasc
  3. */
  4. // Copyright (C) 2007 Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
  5. // Version: 1.0
  6. // Author: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
  7. // Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be>
  8. // URL: http://www.orocos.org/kdl
  9. // This library is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU Lesser General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2.1 of the License, or (at your option) any later version.
  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. // You should have received a copy of the GNU Lesser General Public
  18. // License along with this library; if not, write to the Free Software
  19. // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. #include "chain.hpp"
  21. namespace KDL {
  22. using namespace std;
  23. Chain::Chain():
  24. segments(0),
  25. nrOfJoints(0),
  26. nrOfSegments(0)
  27. {
  28. }
  29. Chain::Chain(const Chain& in):nrOfJoints(0),
  30. nrOfSegments(0)
  31. {
  32. for(unsigned int i=0;i<in.getNrOfSegments();i++)
  33. this->addSegment(in.getSegment(i));
  34. }
  35. Chain& Chain::operator=(const Chain& arg)
  36. {
  37. nrOfJoints=0;
  38. nrOfSegments=0;
  39. segments.resize(0);
  40. for(unsigned int i=0;i<arg.nrOfSegments;i++)
  41. addSegment(arg.getSegment(i));
  42. return *this;
  43. }
  44. void Chain::addSegment(const Segment& segment)
  45. {
  46. segments.push_back(segment);
  47. nrOfSegments++;
  48. nrOfJoints += segment.getJoint().getNDof();
  49. }
  50. void Chain::addChain(const Chain& chain)
  51. {
  52. for(unsigned int i=0;i<chain.getNrOfSegments();i++)
  53. this->addSegment(chain.getSegment(i));
  54. }
  55. const Segment& Chain::getSegment(unsigned int nr) const
  56. {
  57. return segments[nr];
  58. }
  59. Chain::~Chain()
  60. {
  61. }
  62. }